且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在文章列表布局中显示的文章标签

更新时间:2023-11-20 21:47:16

您的php的工作方式是建立一组标签"链接,但实际上并没有echo将其链接到页面.您需要在代码末尾或之后的某个位置(要显示标签的位置)添加此行.

Your php works in the sense that it builds a set of "tag" links but it doesn't actually echo it out to the page. You need to add this line either at the end of your code or somewhere after, where you want to display the tags.

echo $tags;

例如

<?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;
echo $tags;
?>

我不确定您将$args用于什么,除非您在其他地方使用,否则它可能会被删除.

I'm not sure what you're using $args for either, it could probably be removed, unless you're using somewhere else.