简体   繁体   English

使用Nesta CMS按类别过滤文章

[英]Filter articles by category with Nesta CMS

We want to display article summaries for a given category. 我们要显示给定类别的文章摘要。

Standard index page is build like this: 标准索引页的构建如下:

%section.articles= article_summaries(latest_articles)

but I see no way of filtering articles by category. 但我看不到按类别过滤文章的方法。

OK figured it out- To list articles by category, you have to assign pages to a given category AND create an actual category page for each category- ie a page named the same as the category. OK弄清楚了-要按类别列出文章,您必须将页面分配给给定类别,并为每个类别创建一个实际的类别页面,即与该类别相同的页面。

For example, if my page is assigned to categories dogs and cats ... 例如,如果我的网页被分配到类别的狗 ...

Categories: dogs, cats

I'll need to create new pages called dogs.haml and cats.haml , which will then list the articles for those categories with the standard code found in the default page.haml template: 我需要创建名为dogs.hamlcats.haml的新页面,然后将使用默认的page.haml模板中的标准代码列出这些类别的文章:

%section.articles
  = article_summaries(@page.articles)

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

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