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.
When viewing an image node(node_gallery_image), I'm trying to load CCK fields from the parent gallery node(node_gallery_gallery).
I'm doing so inside the theme.inc file and displaying inside the image navigator template(redesigned).
$variables['gallery_link'] = url('node/'. $variables['navigator']['gallery_nid']);
$gallery = node_load($variables['navigator']['gallery_nid']);
$variables['gallery_title'] = check_plain($gallery->title);
... Then using the code below to print out the parent gallery node title.
<span><?php print $gallery_title; ?></span><br>
What needs to be added to my code above to access CCK fields from the parent gallery?
Comments
Comment #1
Prodigy CreditAttribution: Prodigy commentedTo access CCK fields of the parent gallery node, you'll need to perform a node load of $gallery and then set up whichever CCK field you need in the same format used by theme.inc. Also, I'd suggest taking the function out and doing this in your own 'custom' module or template.php.
Example:
And then inside your .tpl.php file ...