繁体   English   中英

Drupal 7-在node--type.tpl.php上打印分类法术语

[英]Drupal 7 - print taxonomy terms on node--type.tpl.php

我在节点中使用以下代码-type.tpl.php,它正在运行。

但是,它在路径中打印术语“#”,而不是术语“机器名称”。 我想念什么?

foreach($node->field_blog_tags['und'] as $tag) {
$terms[] = l($tag['taxonomy_term']->name, 'blog/tags/' . $tag['taxonomy_term']->tid);
}
print implode(', ', $terms);

输出的路径是blog / tag /#。 我希望它是blog / tag / term_machine_name。

任何帮助是极大的赞赏。

Drupal 7取消了术语别名或机器名称,如果您为术语设置url别名,那么这应该可以工作:

foreach($node->field_blog_tags['und'] as $tag) {
    $terms[] = l( $tag['taxonomy_term']->name, 'taxonomy/term/'.$tag->tid );
}
print implode(', ', $terms);

如果分类/术语/ [tid]路径存在,则应使用其URL别名替换。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM