I want to theme CCK content types individually using Smarty templates. In Drupal there are a lot of variables which start with '#'.

For example, with PHPTemplate you would access the value of a CCK field this way:

<?php $node->content['field_my_field]['#value']; ?>

How can you access this variable with Smarty? The following does not work :(

{$node->content.field_my_field.#value}

Seems like Smarty does not allow variables which start with (or contain???) '#'. Would it be possible, that the Smarty Engine for Drupal 6 could work around this somehow? Or is this something wich can only be addressed by the Smarty developers directly?

Comments

djnz’s picture

Assigned: Unassigned » djnz

This is difficult to achieve without modifying Smarty code, which I don't want to do as it would make maintenance difficult. I am looking at a workaround involving pre-filtering the templates, but do not have a time-to-fix yet.

nRick1967’s picture

It could be fixed modifying the following line (in my Smarty version 2.6.26 the line number is 118):

$this->_dvar_guts_regexp = '\w+(?:' . $this->_var_bracket_regexp . ')*(?:\.\$?[\#\w]+(?:' . $this->_var_bracket_regexp . ')*)*(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?';

As mentioned by djnz it implies to modify the Smarty code and be carefull in order to update the Smarty engine.