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.
Hey guys,
I am looking into replacing a string variable
$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
Comment #1
Yorgg CreditAttribution: Yorgg commentedHey guys, I did try this but both are wrong.
I have been told I had to build the term object first.
Can someone please help?
Comment #2
Yorgg CreditAttribution: Yorgg commentedComment #3
Dave ReidYou 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
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:
Comment #4
Yorgg CreditAttribution: Yorgg commentedMany Thanks,
Jorge.
Comment #5.0
(not verified) CreditAttribution: commentedthough I could be more simple with the suport request