该列表将作为文章旁边的侧栏菜单。我该怎么做?!从文章模板中,我唯一设法检索到的是当前文章类别标题,但我不知道如何获取类别对象本身:
$this->item->category_title是否可以通过更改或覆盖默认的文章代码来实现这一点?
发布于 2012-08-20 18:21:16
简短的回答是--不。该模板用于定义主要内容区域和模块位置的布局。
额外的功能应该通过Joomla! extensions来定义,对于你正在寻找的特定功能,你需要一个来自Article Listing section的模块。
您尚未指定Joomla的版本!但我们之前在Joomla!1.5上使用过ArtCats。
发布于 2012-08-20 22:34:38
如果我没理解错的话,这是可能的。然而,正如cppl指出的那样,一个模块可能会更好。这需要一个数据库查询,实际上与模板/布局无关。无论如何,这可能会起到作用:
在templates/your_template/html/com_content/article/default.php中:
<?php
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('a.id, a.title');
$query->from('#__content AS a');
$query->where('a.catid = '.(int)$this->item->catid);
$query->where('a.state = 1');
$query->where('a.id != '.(int)$this->item->id);
$db->setQuery($query);
$articles = $db->loadObjectList();
?>
<ul>
<?php foreach($articles as $item) : ?>
<ul>
<li><?php echo $item->title; ?></li>
</ul>
<?php endforeach; ?>
</ul>https://stackoverflow.com/questions/12035265
复制相似问题