所以我一直在添加你在 Joomla! 中添加到文章的标签,效果很好。但现在我想在 Joomla 中默认的文章列表布局中显示标签。
我找到并覆盖了列表布局,并尝试将标签代码从单个文章布局添加到列表布局。下面是我尝试在列表布局中添加的代码。但是布局中没有显示任何标签..
<?php
// set tags
$tags = '';
if (!empty($this->item->tags->itemTags)) {
JLoader::register('TagsHelperRoute', JPATH_BASE . '/components/com_tags/helpers/route.php');
foreach ($this->item->tags->itemTags as $i => $tag) {
if (in_array($tag->access, JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')))) {
if($i > 0) $tags .= ', ';
$tags .= '<a href="'.JRoute::_(TagsHelperRoute::getTagRoute($tag->tag_id . ':' . $tag->alias)).'">'.$this->escape($tag->title).'</a>';
}
}
}
$args['tags'] = $tags;
?>
如果不清楚,我可以尝试用不同的方式来解释。