简体   繁体   English

在Joomla的剖面视图中获取所有类别的文章

[英]Get all articles of a category in a section view in Joomla

For some reason the Joomla docs are not very friendly to people that don't already know how things are done beforehand. 出于某种原因,Joomla文档对那些事先并未知道事情如何完成的人并不友好。

What I want is, I have two categories in each section, and I want to list all articles in the first one. 我想要的是,我在每个部分都有两个类别,我想列出第一个中的所有文章。 I tried anything like this: 我试过这样的事情:

<p><?php echo count($this->categories); ?></p>
<?php if (count($this->categories) > 0) :
    $category = $this->categories[0];

    $this->items =& $category->getItems();
    echo $this->loadTemplate('items');
endif;
?>

I took that out of the other, pre-defined templates, but this only seems to work within the category-context (for the lack of a better word here). 我从其他预定义的模板中取出了这个,但这似乎只在类别上下文中起作用(因为这里没有更好的词)。 Joomla Docs and Google turned up nothing, am I the only one wanting that? Joomla Docs和谷歌没有发现,我是唯一一个想要的人吗?

That bit of code doesn't work because the Section model and view do not have a function for getting that information. 这段代码不起作用,因为Section模型和视图没有获取该信息的功能。

You would be better off overriding the Category listing than hacking up the Section model and view. 你最好覆盖类别列表,而不是破解Section模型和视图。 Unless there is a compelling reason to do otherwise, change your menu type from Articles >> Section to Articles >> Category >> Blog Layout. 除非有令人信服的理由不这样做,否则请将菜单类型从文章>>部分更改为文章>>类别>>博客布局。 The blog layout will display link, title, and into content just by using the built in parameters. 博客布局将仅使用内置参数显示链接,标题和内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM