I have a nested page template called Categories, in which I keep categories and their subcategories. In a particular design I'm working on, I need to display both the category a page is in, plus the top-most root category. Imagine this structure:
- Cat 1
-- Cat 3
--- Cat 4
- Cat 2
If a blog post I have (which is connected to the category through a relation) is in Cat 3 or Cat 4, I'd like to display both that category and Cat 1. (Example:
I am currently using the following code:
At this moment the code I have supports the display of the parent category. However, this only works when I have two category levels. I want to make sure I always get the root displayed (which is basically: the top-most parent which does not have
Since I could not find a while-loop construct in CouchCMS, I'm stuck on trying to achieve this. Does anyone have an idea? Thanks in advance!
- Cat 1
-- Cat 3
--- Cat 4
- Cat 2
If a blog post I have (which is connected to the category through a relation) is in Cat 3 or Cat 4, I'd like to display both that category and Cat 1. (Example:
- Code: Select all
<p>Cat 1 / Cat 4</p>
I am currently using the following code:
- Code: Select all
<cms:related_pages 'blog_category'>
<cms:pages masterpage='category.php' id="<cms:show k_nested_parent_id />">
<a class="category root" href="<cms:show k_page_link />" title="<cms:show k_page_title />"><cms:show k_page_title /></a>
</cms:pages>
<a class="category" href="<cms:show k_page_link />" title="<cms:show k_page_title />"><cms:show k_page_title /></a>
</cms:related_pages>
At this moment the code I have supports the display of the parent category. However, this only works when I have two category levels. I want to make sure I always get the root displayed (which is basically: the top-most parent which does not have
- Code: Select all
k_nested_parent_id
Since I could not find a while-loop construct in CouchCMS, I'm stuck on trying to achieve this. Does anyone have an idea? Thanks in advance!