Jump to:
| Project: | CCK Blocks |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
I modified the drupal 'story' content type to add four text fields: "left content", "left content title", "right content" and "right content title". I used CCK blocks to place the "left content" and "right content" fields into the left and right sidebars, respectively, and, in configuring the blocks, I used tokens in the titles to try to display the corresponding titles.
The bug is that the token substitution works correctly for only one of the two CCK blocks. The other displays the token (in brackets), with no substitution performed.
To try to understand why, I replaced each of the tokens in the two CCK block titles with the token '[type]'. Then the token replacements work in both titles, but, while the type displayed in the first CCK block title is (correctly) "story", the type displayed in the second CCK block title is (I think incorrectly) "right content". If I remove (that is, don't display) either one of the two CCK blocks, then the other is displayed correctly (with type "story").
So, somehow, the node being passed for the second replacement is not the story node, but a node with type "right content".
Neal
Comments
#1
Neal, thank you for your very detailed report.
I reproduced this bug, but it seems to be a bug in the thoken module.
We call the following line for each block:
$block['title'] = token_replace($title,'node',$node);token_replace seems to work only the first time, we invoke it. It doesn't return a string, when it is ran a second or third time.
Unfortunately, I couldn't figure out the problem in the token module. Therefore I'm asking the developers of that module for help by moving this to the token modules issue list.
#2
#3
I can't duplicate this, sorry.
<?php$node = node_load(2);
echo token_replace('Node title: [title]', 'node', $node) . "\n";
echo token_replace('Node year: [yyyy]', 'node', $node) . "\n";
?>
Results in:
Node title: Consectetuer Plaga Dignissim QuadrumNode year: 2010
I'm not sure token.module is at fault here unless more details can be provided.
#4
Thank you for that hint. I checked our code again and found out, that I used a wrong variable that is only initialized the first time, a node is loaded from the database. Dave, I apologize for wasting your time.
Please check the next -dev release in approximately 12 hours.
#5
Hey, good to know it's not a token bug like I thought. Thanks for the report back!
#6
#7
Automatically closed -- issue fixed for 2 weeks with no activity.