Use token in php code on drupal website

I use some tokens on my drupal site.

I have php code where I need to use a token.

print '[token]'; 

This works fine, but I need to use it in a function like

 myfunctionname('[token]') { } 

This does not work. How to use this token in php code without using the print function. I am trying to encode a string using a special function. Therefore, I have to use the value from this token as a parameter in the function.

+4
source share
2 answers

I solved the problem by adding some token to simplenews tokens. Thanks for your help anyway.

-1
source

You can try the t() function, for example t('[token]') .

But it seems that token_replace () is the function you want to use.

+4
source

Source: https://habr.com/ru/post/1385970/


All Articles