Forum
Categories & Collections: Displaying current category title?
In Runway I have a page that lists out a collection base on category (below). How do I display the Title of the category that is being viewed? <perch:category id="catTitle" />
obviously won't work but is there something similar based on the category slug that needs to be used?
<?php
perch_collection('Resources', [
'category' => 'departments/'.perch_get('cat'),
]);
?>
I think you can use this in your template to get the catTitle:
Alex
Thanks for the reply Alex, I tried the code below following your advice - but it still doesn't display the catTitle.
What does it display?
It displays nothing.
Which version are you running? 2.7.10?
Yes 2.7.10.
That's very odd. I'll see if I can reproduce it.
Source for the page showing where the Category Title output should be and the list of relevant categories:
Yes, I'll see if I can reproduce it.
Hi Dan,
From your code above, it looks like the
<perch:categories...
code is in the wrong place. It should be inside a content template.Alex
Alex,
The code above is for a page acting as an archive for a particular category.
The following code is used for the Content template "resource.html':
But the code is in a template, not in the page, correct?
For clarity here is my process (In Runway)...
It is working all fine - all I need to figure out is how to display the category title in the archive.php master page. I have supplied the code for resource.html, departments.html and archive.php so that it is clear.
categories/departments.html looks like this:
content/cpi/resource.html looks like this:
pages/resource-bank/archive.php looks like this:
archive.php
is a page. You can't use template tags in a page. They have to go in a template.Thanks gents!
Still getting my head round how Perch works.