简体   繁体   English

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

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

I am using the following code in my node--type.tpl.php and it is working. 我在节点中使用以下代码-type.tpl.php,它正在运行。

However it is printing the term # in the path instead of the term machine name. 但是,它在路径中打印术语“#”,而不是术语“机器名称”。 What am I missing? 我想念什么?

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

The path that is output is blog/tag/#. 输出的路径是blog / tag /#。 I would like it to be blog/tag/term_machine_name. 我希望它是blog / tag / term_machine_name。

Any help is greatly appreciated. 任何帮助是极大的赞赏。

Drupal 7 did away with term aliases or machine names, If you set the url alias for the terms then this should work: Drupal 7取消了术语别名或机器名称,如果您为术语设置url别名,那么这应该可以工作:

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

The taxonomy/term/[tid] path should be replaced with its url alias if it exists. 如果分类/术语/ [tid]路径存在,则应使用其URL别名替换。

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

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