Forum

Thread tagged as: Question, Runway, Blog

Different visual theme of homepage with different post type - is it possible?

I have a site with three main post types - news, apps and blog. Each post type has it's own visual template. The news is bright white, apps are yellow, the blog is green. The homepage displays only one (most recent) post (+ navigation and footer).

Is it possible to have my homepage look different, depending on the actual post type active? For example, if the most recent post is News, the theme of the homepage will be bright white. If the next post is blog, theme of the homepage will be green etc.

And of yes, should I do it with blog sections or multiple blogs or different collections (in Runway) or....?

Thanks!

Tomislav Jurisic

Tomislav Jurisic 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you can use the template option to specify a template to use on your homepage. Within that template you can use perch:if to test postTemplate and switch to vary things as necessary between your types of post.

Thanks Drew! Can you just make a rugh sketch of a code example that I need to use with perch:if tag?

    <?php
    perch_content_create('News', array(
     'template'   => 'news_template.html',
    ));
    ?>

Do I use perch:if inside of php code or directly in template or....?

Drew McLellan

Drew McLellan 2638 points
Perch Support

<perch:if id="postTemplate" value="news.html">
     This is a news item.
</perch:if>

Thanks Drew, will try that!!