Forum
Blog subcategories path
Hello all,
I followed Rachel's Blog video guide and I managed to reproduce the result. I tried to populate my Blog setup with subcategories:
This is my markup:
<ul>
<li>
<a href="#">Item Level 1</a>
<ul>
<li>
<a class="cur" href="#">Sub item Level 2</a>
<ul>
<li><a href="#">Sub item Level 3</a></li>
<li><a href="#">Sub item Level 2</a></li>
<li><a href="#">Sub item Level 2</a></li>
</ul>
</li>
<li>
<a href="#">Sub item Level 2</a>
<ul>
<li><a href="#">Sub item Level 2</a></li>
<li><a href="#">Sub item Level 2</a></li>
</ul>
</li>
</ul>
</li>
</ul>
When I add the subcategories in perch CMS at "Listing categories in ‘Blog’ set" I get the correct visual tree representation and the correct path e.g:
blog/item-level-1/
blog/item-level-1/sub-item-level-2/
blog/item-level-1/sub-item-level-2/sub-item-level-3
etc.
I use the template: perch/templates/blog/category_link.html as Rachel does in the video guide.
<perch:before>
<h3 class="[ u-h6 u-text-align--right ]">Categories</h3>
<hr>
<ul>
</perch:before>
<li>
<a href="archive.php?cat=<perch:category id="catSlug" />"><perch:category id="catTitle" /> (<perch:category id="count.blog.post" when-empty="0" />)</a>
</li>
<perch:after></ul></perch:after>
<perch:before>
and this is what is being produced:
<ul>
<li><a href="archive.php?cat=item-level-1">Item Level 1 (1)</a></li>
<li><a href="archive.php?cat=sub-item-level-2">Sub item Level 2 (1)</a></li>
<li><a href="archive.php?cat=sub-item-level-3">Sub item Level 3 (1)</a></li>
</ul>
What do I need to do to have this one produced?
<ul>
<li>
<a href="#">Item Level 1</a>
<ul>
<li>
<a class="cur" href="#">Sub item Level 2</a>
<ul>
<li>
<a href="#">Sub item Level 3</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
I must tell you that my experience with perch CMS is extremely limited
Thank you in advance
Do you mean in terms of customising the HTML, or setting the right options to get the level of navigation?
I was referring to the HTML. How can I restrict the subcategories to only be shown under the proper categories?
You can test for
catDepth
in the template and display different markup.If you add
<perch:showall />
to your template, you should be able to see all the variables that are available for you to display and test against.Hello again,
this is what I have figured out:
This will only display the 1st-level categories.
So if lets say we wanted to create something like this:
this code would only render the category Animals
If I wanted to output the first AND the second level categories what should I do?
The above does not work. Any idea why?
When you say it doesn't work - what output do you get?