在变量中存储令牌替换的正确方法是什么?或者我应该麻烦直接打电话给他们吗?
比如:
$author_uid = [node:author:uid];
$name = [node:title];
$picture = [node:field-image-upload:file];
$link = [node:url];
正在给我一个错误:
PHP Parse error: syntax error, unexpected ':'
我做错什么了吗?
同样关于这条线:
$picture = [node:field-image-upload:file];
我真正想得到的是图像文件的url链接。如何使用代币进行此操作?
如果您想在变量中存储令牌,您应该编写$author_uid = "[node:author:uid]";
请注意,令牌只是一个字符串
如token.inc
的文档中所述,令牌系统是一个…
API函数,用于将文本中的占位符替换为有意义的价值观
如果你想要URL链接到图像文件,你可以做:
$picture = token_replace('[node:field-image-upload:file]', array('node' => $node));
请注意,您需要已经有$node
对象才能传递到令牌替换函数中。