【发布时间】:2014-07-23 14:51:01
【问题描述】:
我正在使用 joomla 3.2.3 开发一个网站,我一直在向我的 joomla 文章添加一些标签,这些标签在文章的内容上方显示。
对于列表,我使用“菜单项类型:文章 > 类别列表”,我希望它也显示列表中的文章标签,例如像这样:
[标题] [作者] [标签]
由于 joomla 在文章管理器选项中不支持此选项以在列表布局中显示标签,因此我一直在尝试通过编辑列表布局文件将其添加到列表中。 在这里我做了一个模板覆盖:
com_content > 类别
其中包括列表文件:
- default.php
- default.xml
- default_article.php
- default_children.php
然后我尝试修改这个文件,它创建了列表布局:
.../templates/my_template/html/com_content/category/default_articles.php
为了为列表布局创建标签列,我在第 100 行附近的部分添加了以下代码:
<?php if ($this->params->get('show_tags')) : ?>
<th id="categorylist_header_tags">
<?php echo JHtml::_('grid.sort', 'JTAG', 'tags', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
这在我的类别列表视图中创建并显示第二列,标题为:标签(如果在文章管理器选项中设置为“显示”)
为了让标签显示在列字段中,我认为我需要在第 181 行附近的部分中为标签添加代码,我尝试在其中添加此代码:
</td>
<?php endif; ?>
<?php if ($this->params->get('show_tags', 1)) : ?>
<<td headers="categorylist_header_tags" class="list-tags">
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
<?php echo JText::sprintf('JTAG', $article->tags->itemTags); ?>
</td>
<?php endif; ?>
这是我需要帮助的代码,因为它不能完全工作,它只在字段中显示文本“标签”(来自“JTAG”),并且不显示代码中的文章标签:
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
我从“文章”视图默认布局中获取,以查看标签是如何呈现的。 但是这段代码显然不能直接在类别列表布局中工作或没有任何效果。
试图看看这个帖子: Article Tags shown in Article List-Layout
但无法让这篇文章中的代码为我工作:
【问题讨论】:
-
请显示您正在使用的确切代码,并检查您是否有该视图的布局覆盖。
-
已经更新了我迄今为止所做的问题,我已经添加了我用来尝试显示标签的代码。我已经创建了 List-layout 'default_article.php' 的覆盖(在问题的开头提到)
标签: php listview joomla joomla3.0