You also have the ability to nest multiple {articles}
tags. This can be useful to output another set of articles for every article shown.
You can also use this technique to use nested If Structures.
Nested Articles Tag
To create nested sets, append the {article}
or{articles}
tag of the nested set with an extra name or id, for example -others
.
The example below will show one article per category from the parent category "Animals" (so one article from the "Dogs" subcategory, one article from the "Cats" subcategory, and so on). And for each of those articles, it will show a set of articles for the other animals contained in the respective category.
Check out the syntax and the respective result:
{articles category="Animals" include_child_categories="true" one_per_category="true" separator="<hr>"}
<h4>[link][title][/link]</h4>
More articles from the "<b>[category]</b>" category:
{articles-others category="[category]" articles="![id]" separator=", "}[link][title][/link]{/articles-others}
{/articles}
Beagle Dog
More articles from the "Dogs" category: Bulldog, German Shepherd, Labrador Retriever
Bengal Cat
More articles from the "Cats" category: Persian Cat, Siamese Cat, Shorthair Cat
Arabian Horse
More articles from the "Horses" category: Morgan Horse, Quarter Horse, Thoroughbred
Don't forget to close each articles set with a closing tag using the same extra id (in this example: {/articles-others}
). If you don't close every set, you will get unwanted results.
Nested If Structures
The nested Articles tag also allows you to use nested If Structures, which wouldn't otherwise be possible.
You can simply wrap your nested set of {if}
tags in a nested {article}
or {articles}
tag. For example:
{articles category="Animals" include_child_categories="true" separator="<hr>"} <h4>[link][title][/link]</h4>
{if category = 'Cats'}
This is a cat.
{article-nested id="[id]"}
{if 'furry' IN tags}
It's also furry.
{elseif 'fluffy' IN tags}
It's very fluffy.
{/if}
{/article-nested}
{/if}
{/articles}