Posted by staminna on January 6, 2012 at 6:58pm
3 followers
Jump to:
| Project: | Token |
| Version: | 7.x-1.0-beta7 |
| Component: | Documentation |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
| Issue tags: | PHP, strings, token_replace, variables |
Issue Summary
Hey guys,
I am looking into replacing a string variable
<?php
$my_string_var = token_replace('[term:name]');
?>I though this would be very straight forward
I can't understand the why this isn't working since token_replace function calls the hooks. Can someone help me with this?
Best Regards,
Jorge.
Comments
#1
Hey guys, I did try this but both are wrong.
<?php$mystring_var = print token_replace('[term:name]', array('vocabulary' => $this->vocabulary ));
$mystring_var = print token_replace('[term:name]', '#node' => $term);
?>
I have been told I had to build the term object first.
Can someone please help?
#2
#3
You can't use 'print' since that outputs the string and doesn't allow it to be assigned to a variable.
You are needing something like
$mystring_var = token_replace('[term:name]', array('term' => $term));You need a taxonomy term object/entity to provide to token_replace(). If you have that object, then I'm not sure why you need token replacement since you can just do:
$mystring_var = $term->name;#4
Many Thanks,
Jorge.
#5
Automatically closed -- issue fixed for 2 weeks with no activity.