[英]How to add “tags” in joomla 3.x blog layout
I would like to add the article tags in my blog layout in joomla 3.x. 我想在joomla 3.x的博客布局中添加文章标签。 I overwrote the joomla layout files and tried to add the code below in blog_style_default_item_title.php
as it is in article 我改写了joomla布局文件,并尝试在blog_style_default_item_title.php
添加以下代码,如本文中所述
<?php if ($params->get('show_tags', 1) && !empty($this->item->tags)) : ?>
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
<?php endif; ?>
but it did not work. 但它没有用。 I guess variable name is not the good one. 我猜变量名不是一个好名字。 Any ideas? 有任何想法吗?
My knowledges in php language are pretty weak but I had a look and tried a few think. 我对php语言的了解还很薄弱,但是我看了一下,并做了一些尝试。
I finaly got something by adding code below in /com_content/category/blog_items.php
我/com_content/category/blog_items.php
通过在/com_content/category/blog_items.php
添加以下代码获得了一些东西
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
but i would like to add "tags" on the title line so in blog_style_default_item_title.php
file 但我想在标题行上添加“标签”,以便在blog_style_default_item_title.php
文件中
<?php
defined('_JEXEC') or die;
// Create a shortcut for params.
$params = $displayData->params;
$canEdit = $displayData->params->get('access-edit');
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('behavior.framework');
?>
<?php if ($params->get('show_title') || $displayData->state == 0 || ($params->get('show_author') && !empty($displayData->author ))) : ?>
<div class="page-header">
<?php if ($params->get('show_title')) : ?>
<h2>essai
<?php if ($params->get('link_titles') && $params->get('access-view')) : ?>
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($displayData->slug, $displayData->catid)); ?>">
<?php echo $this->escape($displayData->title); ?></a>
<?php else : ?>
<?php echo $this->escape($displayData->title); ?>
<?php endif; ?>
</h2>
<?php endif; ?>
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
<?php if ($displayData->state == 0) : ?>
<span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span>
<?php endif; ?>
</div>
<?php endif; ?>
But i have a error??? 但我有一个错误?
Here is how they are added to individual weblinks 这是将它们添加到单个Web链接的方法
<?php $tagsData = $item->tags->getItemTags('com_weblinks.weblink', $item->id); ?>
<?php if ($this->params->get('show_tags', 1)) : ?>
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($tagsData); ?>
<?php endif; ?>
What you would want to do is something similar but for com_content.article and make sure the $item and $this->params references match what you have. 您想要执行的操作与com_content.article相似,并确保$ item和$ this-> params引用与您的内容匹配。
Here a picture of the design I would like 这是我想要的设计图片
And he below the way the page id made of (as i understood it) 而且他在页面ID的构成方式之下(据我所知)
in blog_item.php there is this line which call the 在blog_item.php中,有这条线称为
...
<?php echo JLayoutHelper::render('joomla.content.blog_style_default_item_title', $this->item); ?>
....
and so in blog_style_default_item_title.php 在blog_style_default_item_title.php中也是如此
....
<div class="page-header">
<?php if ($params->get('show_title')) : ?>
<h2>essai
<?php if ($params->get('link_titles') && $params->get('access-view')) : ?>
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($displayData->slug, $displayData->catid)); ?>">
<?php echo $this->escape($displayData->title); ?></a>
<?php else : ?>
Did I make a mistake?? 我做错了吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.