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

Yorgg’s picture

Title: using token values inside php variables » making token values into string variables

Hey guys, I did try this but both are wrong.

$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?

Yorgg’s picture

Title: making token values into string variables » passing token values into string variables
Dave Reid’s picture

Status: Active » Fixed

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;
Yorgg’s picture

Many Thanks,
Jorge.

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

though I could be more simple with the suport request