Forum
Does a category set have still have to be called 'blog' to work with the Blog ap...
Hi
I'm trying to get a category archive page working with a multi-blog, but I'm not having much luck.
After a quick search in the forum I found a post I wrote last year.
I was experiencing a similar problem then as I am now.
My blog category archive pages are working, but my news category pages aren't.
My blog category setup:
<perch:categories id="categories" set="blog" label="Categories" display-as="checkboxes">
And my news category setup:
<perch:categories id="newsCategories" set="news" label="Categories" display-as="checkboxes">
At the bottom of the previous post I asked:
Does the category set have to be called 'blog' to work with the Blog app?
Drew replied:
Yes it does - that's what you just proved by changing it and breaking the functionality, then changing it back and it all working again.
- Is this still the case?
- Do all my categories for each individual blog need to be in the same category set?
Diagnostic Information
- Perch Runway is up to date (2.8.19)
- PHP 5.6.10 is up to date
- MySQL 5.5.42 is up to date
- Image processing available
Sorry, I've just checked the documentation
Hmmmm... I'll have another look over the templates I've made - try to find out what's going wrong...
The default is called
blog
. If you don't use that you need to make sure you give the correct category path when filtering by category.Thanks Drew
Here's the solution:
In archive.php add the category path like this:
'category' => 'news/' . perch_get('cat')
The code above displays the archived posts for the blog called news, but it's not displaying the category name in the
Archive of
titleHow would I display the news category title here?
If
cat
is a slug, you need to turn it into a category path.Is this in relation to my first post?
I can display the archived posts of the news blog.
I'm having trouble with displaying the
category title
on thearchive
page. I can display the category slug using this:But I really need to output the title.
If the blog isn't called blog (in this case it's called news) how do I include the name of the category in the Archive of title?
Solved
I used this in my
post_in_list.html
template:In
archive.php
I deletedecho '<h1>Archive of: '.perch_blog_category(perch_get('cat'), true).'</h1>';
Ta-Dah! :)
Thanks for this! I was struggling with the same situation. Most sites I create use the blog as News sections so I don't like the phrase blog...
Ooh, I am so close on having this set up properly, following Stephan's code from above.
I ended up making a "post_in_category_list.html" template instead of using the perch:if conditional above. So my code in the template looks like this:
The only trouble I'm having is that if a post has more than one category assigned, they both show up in the h1 element.
So, if I have categories Blue and Green, and 5 posts categorized as Green, and one of those also is categorized as Blue, and I go to "archive.php?cat=green", the h1 reads: "Archive of: Blue Green".
I'm really not sure how to go about getting just the one category title ("Green" in the above example) that I want in the h1. Can anyone help point me in the right direction?
Hi Laura
If you need to output the title of the category, use this solution instead.
I found the default archive template outputs the category title fine, as long as your blog is called blog. But you hit a problem when you have a second blog, that isn't called blog. I had a blog called DIY tips. Hopefully, the link above will help. Good luck!
Oh that's perfect! Thanks so much for the pointer!