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 am tying to add icons to calendar nodes based on node type in the monthly calendar view by creating a .cal-icon-(type) class within the calendar-month-node.tpl.php template
<div id="<?php print $field['id']; ?>" class="view-field view-data-<?php print $field['id'] ?> cal-icon-<?php print $node->type ?>">
the code just creates the class cal-icon-
Comments
Comment #1
setvik CreditAttribution: setvik commentedI'm unable to reproduce this behavior.
I just installed did a fresh install of:
I enabled the default Calendar view and edited calendar-month-node.tpl.php template as you described above and created a story node.
It shows up on the calendar with a class of "cal-icon-story".
First make sure you're running the latest version of Calendar (6.x-2.0) and that there are no typos in the print statement you placed in your template file...
Next, try printing the entire $node object out so you can examine which of it's properties made it to the template file: i.e. stick a
<?php print_r($node) ?>
in your template file, refresh the page and examine the output in the page source. If $node->type is blank there,stick a
$print_r($vars['node']);
at the end of the template_preprocess_calendar_month_node() function in calendar/theme/theme.inc, refresh the page, examine the source, and view the node properties...If the above debugging shows that $node->type is set in the preprocess function, then it's possible that another module's preprocess function is executing later and deleting the node type before it gets to the template file
Hope that helps you track the issue down.
Comment #2
Stephen666 CreditAttribution: Stephen666 commentedHi setvik
thank you for the reply I have resolved the problem thanks to information from this post Loading $node object from view which contained the line
I modified my template code from
to
which works. thanks for the reply contain some useful tips for further investigation.
Comment #3
Stephen666 CreditAttribution: Stephen666 commented