Bluehost: Web hosting from $3.95/month. Sign Up

Managing content items with Perch Blocks and Collections

Posted on by Clive Walker in Perch

One of the best features in Perch CMS is Perch Blocks which enables website editors to choose specific content types for any area of their site. Together with Collections in Perch Runway, this is an incredibly powerful method of content management that is easy to implement. And, after all, isn't that what a content management system is (should be) all about?

Here's the Perch Blocks template I'm using to manage content on an area of CVW Web Design.

<perch:blocks>
    <perch:block type="text" label="Text">
            <perch:content id="text" type="textarea" html="true" editor="redactor" label="Text" />
    </perch:block>
    <perch:block type="subheadingtextbox" label="Subheading & Text">
        <div class="sideBox">
            <h2><perch:content id="heading" type="text" label="Heading" html="false" required="true" title="true" /></h2>
            <perch:content id="text" type="textarea" label="Text" html="true" editor="redactor" />
        </div>
    </perch:block>
    <perch:block type="featurebox" label="Sidebar Feature">
        <div class="sideBox sideBox4">
            <h2><perch:content id="heading" type="text" label="Heading" html="false" required="true" title="true" /></h2>
            <perch:content id="text" type="textarea" label="Text" html="true" editor="redactor" />
        </div>
    </perch:block>
    <perch:block type="testimonial" label="Testimonial">
              <perch:related id="testimonial" collection="testimonials" label="Select testimonial">
                <perch:template path="content/testimonial-in-sidebar.html" />
              </perch:related>
    </perch:block>
    <perch:block type="sidebaritem" label="Sidebar Item">
            <perch:related id="sidebaritem" collection="Sidebar Item" label="Choose Sidebar Item">
                <perch:template path="content/sidebox-evolved.html" />
              </perch:related>
    </perch:block>
</perch:blocks>

In this template, I have five Blocks which are:

  1. Text
  2. Sub-heading and text
  3. Sidebar feature (another sub-heading and text block)
  4. Testimonial Collection Item
  5. Sidebar Collection Item

I admit that I could refine this and I don't really need the Sidebar Feature (which differs from the Sub-heading and text block only in the <div> class I'm using) but, hey, this is a real-world example :-)

The last two blocks are most interesting. I'm using the <perch:related> tag to pull in items from two Collections (Perch Runway), a Testimonial Collection and a Sidebar Item Collection. I'm also using a <perch:template> tag so that a specific sub-template controls how each item is displayed.

The screenshot below shows the Testimonial block when I choose "+ Testimonial". I get a dropdown list and I can simple choose the Testimonial I want to use.

Screenshot: CVW Web Design Perch admin

Screenshot: CVW Web Design Perch admin

My Testimonials are managed as a normal Collection in Perch Runway. However, using the <perch:related> tag in Perch Blocks means that I can choose which one to use anywhere on my site. Yay!

Overall, the combination of Perch Blocks with Collection items is very powerful and easy to set up. When I think of the virtual hoops that I need to jump through with some other popular CMSes to achieve something similar, I realise that Perch is much, much better.

How do you use Perch Blocks and Collections? Let me know in the comments.

Better still, write a blog post about it and I'll add a link in a future issue of the Perchology newsletter!

Leave a comment

A simple question that helps prevent automated form fillers.

© 2016 Clive Walker