Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I used this code for a related content block (which I found in your handbook):
if (arg(0) == 'node' && is_numeric($nid = arg(1))) {
$host_node = node_load($nid);
$grouped = relatedcontent_variable_output_grouped($host_node->type);
if($groups = relatedcontent($host_node, $grouped)) {
foreach($groups as $group => $nodes) {
if ($nodes) {
$links = array();
foreach($nodes as $node) {
$links[] = l($node->title, "node/$node->nid");
}
$title = relatedcontent_group_title($group, $grouped, $host_node->type);
print theme('item_list', $links, $title);
}
}
}
}
This works great...but it's not very visually stimulating. I would like to also like to display the first thumbnail from inside the image field inside this cck node. It's an imagecache field. Any suggestions?
And while we're at it, what's the best way to reference and display the other fields from inside the node inside this block?
Sorry, this is all probably very easy for you, but I'm not an experience php/drupal person.
Thanks in advance!
Comment | File | Size | Author |
---|---|---|---|
#1 | Screenshot-4.png | 177.34 KB | peter-boeren |
Comments
Comment #1
peter-boeren CreditAttribution: peter-boeren commenteddoubledoh,
thank you for your two questions. The first is not easy to explain but I will give it a try. Below is the example of the code resulting in a table with an image and a title. But it is also possible to put the values in divs and theme them yourself with css.
In this code are a few assumption you will have to alter:
I hope this helps. Attached is a screenshot with the results, it is still not very stimulating but you can create your own theme function if you know how to gather the information.
Question 2: You have seen how to gather information from the database. Due to the fact that we have a node id, you can also use node_load($nid) to get all the fields of a node, but this has some negative influence on performance when using on large website (5000+ nodes).
Comment #2
peter-boeren CreditAttribution: peter-boeren commented