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

setvik’s picture

Status: Active » Postponed (maintainer needs more info)

I'm unable to reproduce this behavior.

I just installed did a fresh install of:

  • Drupal 6.10
  • Views 2.3
  • Calendar 6.x-2.0
  • Date 6.x-2.0

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.

Stephen666’s picture

Hi 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

Unless you're using the 'node' row style, views never loads the node object.

I modified my template code from

cal-icon-<?php print $node->type ?>

to

cal-icon-<?php $ref_node = node_load($node->nid) ; print $ref_node->type ?>

which works. thanks for the reply contain some useful tips for further investigation.

Stephen666’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)