3

[Newb]Can i print an array inside a $node->**content item name**??

http://drupal.org

Hi there. I am developing my personal module based on the "annotation module" proposed by "Pro Drupal Development" book.
I am making my own modifications and i am trying to do the following step:

I have this code:

$query = db_query('SELECT note FROM {annotations} WHERE nid = %d
     AND uid = %d', $node->nid, $user->uid);
    while($row = db_fetch_array($query)){
     echo "Annotation =>> " . $row[note] . " <br>");
    }

This just show me all the annotation previously added to a specific node and by a specific user (the one that added the node ofc). As a matter of fact the list of annotations are just showed on the top of the web page...above the header because no content items are speficied to show them in a specific area of the page.

To fix this, i created 2 forms as "boxes" for my query result.

$form['annotateshow']=array(
'#type'=>'fieldset',
'#title' =>t('Show Annotations'),
);

$form['annotateshow']['content']=array(
'#type'=>'item',
'#value' => isset($node->annotations) ? $node->annotations : ' ',
);

return $form;
}

All i have to do now is writing the result of the query inside $node->annotations

I ranged from silly tries to more "tought" ones.

1)
$query = db_query('SELECT note FROM {annotations} WHERE nid = %d
AND uid = %d', $node->nid, $user->uid);

read more

Read »
Created by Dplanet 1 year 36 weeks ago
Category: Modules   Tags:

PSD to Drupal Theme

Drupal Development

Module Development

Get an Estimate

Tags for [Newb]Can i print an array inside a $node->**content item name**??

Recent comments