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.
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:
%section.articles
= article_summaries(@page.articles)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.