Hi,
i wrote a php Block to display a type of nodes.
When the code is in the block, it works fine.
But if I create a PHP Page, the results are not show in the page.
Is there a difference?? Why it doesn't work?
Here are my code:
$nodes = array();
$sql = "SELECT n.title, n.nid, flexinode_1.numeric_data AS flexinode_1, flexinode_2.textual_data AS flexinode_2, flexinode_3.textual_data AS flexinode_3 FROM {node} n
LEFT JOIN {flexinode_data} flexinode_1 ON n.nid = flexinode_1.nid
LEFT JOIN {flexinode_data} flexinode_2 ON n.nid = flexinode_2.nid
LEFT JOIN {flexinode_data} flexinode_3 ON n.nid = flexinode_3.nid
WHERE n.status = 1 AND n.type = 'flexinode-1' AND flexinode_1.field_id = 1 AND flexinode_2.field_id = 2 AND flexinode_3.field_id = 3 ";
$output .= "Campagnes";
$nodes = pager_query($sql, 2);
while ($node = db_fetch_object($nodes)) {
$format = ($node->flexinode_1 == '1') ? "d.m.Y, H:i" : "d.m.Y";
$output .= '
' . (format_date($node->flexinode_1, 'custom', $format) . ($node->flexinode_1 == '1') ).'
'.'flexinode_3.'">'. $node->title. ''.'
'.$node->flexinode_2 .'
';
}
return $output;
Comments
Printing vs. returning
In Drupal 4.4, you have to return output from blocks, and print output from pages. This disjunction has been fixed in 4.5, so that you can use either method in either place now.
Add related taxonomy to my php flexinode block
Thanks JonBob.
I couldn't figured it out myself due at my lack of my PHP Knowledge.
________________-
How can I add the taxonomy related to each flexinode in my listing?
Here is my code again:
$nodes = array();
$sql = "SELECT n.title, n.nid, flexinode_11.numeric_data AS flexinode_11, flexinode_12.textual_data AS flexinode_12, flexinode_13.textual_data AS flexinode_13 FROM {node} n
LEFT JOIN {flexinode_data} flexinode_11 ON n.nid = flexinode_11.nid
LEFT JOIN {flexinode_data} flexinode_12 ON n.nid = flexinode_12.nid
LEFT JOIN {flexinode_data} flexinode_13 ON n.nid = flexinode_13.nid
WHERE n.status = 1 AND n.type = 'flexinode-3' AND n.static='1' AND flexinode_11.field_id = 11 AND flexinode_12.field_id = 12 AND flexinode_13.field_id = 13 ";
$nodes = pager_query($sql, 2);
while ($node = db_fetch_object($nodes)) {
$format = ($node->flexinode_11 == '1') ? "d.m.Y, H:i" : "d.m.Y";
$output .= ''.(format_date($node->flexinode_11, 'custom', $format) . ($node->flexinode_11 == '1') ).''.'
'.'flexinode_13.'" class="lien3">'. $node->title. ''.''.'
'.''.$node->flexinode_12.'';
$output .= '
';
}
print $output;