HI,

How do I include data straight from my database into my contemplate template?
Also, how do I include data from a differenty content-type into my contemplate template?

I've researched everywhere. Thought I remembered seeing the solution a long time ago for an older version oof contemplate, but now, can't find it. anyway.

Help, please
Connie

Comments

conniec’s picture

Title: Include data from database or from a different content-type » Contemplate-how to add another content-type?

Hi all,

I've only found one way to add in a different content type, but it didn't work for me.
I want to add in a few fields from a different content type or
straight from the database.

Any help?

Connie

jrglasgow’s picture

to add data from another content type you need to use the node_load() function. With this function you can load all the alues from another node. i.e.

$new_node = node_load(275);
// this will load the contents of node # 275 into the object $new_node

to add something from the database use the db_query() function

$sql = "SELECT something_field FROM {some_table} WHERE field_1='%s' AND field_2='%s'"
$result = db_query($sql, $condition_1, $condition_2);

you can also use any function in the Drupal API

conniec’s picture

Status: Active » Closed (fixed)

Exactly what I needed. Thanks!

closing issue

Connie