Forum

Thread tagged as: Blog

Multiple Blogs

Hi I want to have 3 blog type pages on my website. Ie a blog with 3 categories (blog, casestudy and news).

I have 3 blog index pages (index-news.php etc) which work to list the relevant blog entries by category.

However, when I go into each individual entry, I go to the standard blog.php page - and i need to make this look different for each type of category.

Is there somewhere i can specify which blog.php page I want each blog-index page to use, rather than defaulting to the standard post.php file

Thanks

cow shed

cow shed 0 points

  • 6 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

I would suggest using Blog Sections rather than Categories for this, that also would keep categories for further categorisation if you need it.

https://docs.grabaperch.com/addons/blog/page-functions/perch-blog-sections/

Thanks - I've looked at sections, but they also seem to display the post information on post.php and its this page I'm trying to put some customisation on

I can use the sections functionality to create different section.php pages - but when I click on the list of posts they go through to post.php. I cant see how I can get each different section.php to link to its own post.php. Is this possible?

Otherwise I can try and do something with some if statements to display different info on the post.php page, but its not as neat!

Thanks

Drew McLellan

Drew McLellan 2638 points
Perch Support

post.php isn't part of Blog, it's just an example page. You can create as many different pages as you need.

The built in postURL ID will give you the URL specified in the Settings, but that's just a convenience. You don't have to use it to built your links. You can link to any post page you want to.

I'm sure I'm missing something obvious - but I cant see where the link to the post.php file is so I cant see how to link to anything else. I can only see : <?php perch_blog_recent_posts(10); ?> Where do I change the link to post.php?

I have got round it for now by displaying the post fields directly in my post - eg <?php perch_blog_post_field(perch_get('s'), 'postTitle'); ?> and using lots of ifs! But it would be good to know the correct way for future sites!

Thanks

Drew McLellan

Drew McLellan 2638 points
Perch Support

Change the link in your templates.

Thanks but which template? For example my post_in_list template goes to post.html but I cant see where in that to point to a different post.html THanks

My post-in-list that goes to post.php is : <perch:before> <ul></perch:before> <li> <p class="news-panel-text"><a href="<perch:blog id="postURL" />" rel="bookmark" ><perch:blog id="postTitle" /></a></p> </li> <perch:after> </ul> </perch:after>

Drew McLellan

Drew McLellan 2638 points
Perch Support

This is the link:

 <a href="<perch:blog id="postURL" />" rel="bookmark" >

The postURL ID references the setting on the Settings page. If you don't want to use that, change it:

<a href="/wherever-you-want" rel="bookmark" >

brilliant - thanks

just one thing - i want to have two different post.php depending on what the cat slug is - but settings only lets me set one. Is there a way I can up post1.php and post2.php depending on if cat= blog or cat=news?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes:

<perch:categories id="categories" set="blog" label="Categories" display-as="checkboxes">
    <perch:if id="catSlug" value="blog">
            <a href="...">...</a>
    </perch:if>
    <perch:if id="catSlug" value="casestudy">
            <a href="...">...</a>
    </perch:if>
    <perch:if id="catSlug" value="news">
            <a href="...">...</a>
    </perch:if>
</perch:categories>