Forum

Thread tagged as: Question, Problem, Configuration

Adding in Perch Blocks to a page running off of a Master Page

Please bear in mind that I am new to Perch and am attempting to get to grips with what you guys will call the "basics".

The End Result that I'm after achieving is to have a set of individual pages, all of which run off of a Master Page template... so that I can amend that one Master template and see all the child pages amend to follow suit.

BUT there are going to be obvious individuality to each of those child pages. One individuality is the bottom section of the page's layout, where I want the child page's creator to be able to choose if that section is either 2-column, 3-column or 4-column. The easiest way to do this (with my limited knowledge) is to use Perch Blocks... where I'll have a set of 3 individual block(s) inside of an outer pair of encompassing perch:blocks tags. Each individual perch block would contain the code specific for either 2-column, 3-column or 4-column. The Admin user would the click to add in one of the 3 options... and then fill in the actual content.

But I'm unsure as to where I put my actual blocks. From the video demos I've watched, it appears the blocks are HTML template files inside of the "content" subdirectory. This means there's gonna have to be something to call the blocks template from my Master Page template (to then feed the contents through to the actual child pages.

Inside the Master Page, I already have code like:

<?php
    // create the region first
    perch_content_create('pageBodycopy', array(
    'template' => 'pmsa_template01_header_text_block.html'
    ));

    // output the region
    perch_content('pageBodycopy');
?>

...Do I assume that I'd use the same technique to call my bespoke block(s) template file? And then the contents of the blocks themselves will create the form fields within Admin?

m.

Martin Lowe

Martin Lowe 0 points

  • 2 years ago

Blocks live inside a content template so yes you’d call them with a content function. Blocks are movable sections inside a region so are more useful for content than layout.

If the layout for each column is the same then you can use multiple item regions instead. You’d then use conditionals or css to layout the output into columns based upon the number of regions added by the user. Personally I’d rather not rely on end users to make layout decisions.

Alternatively you could have a dropdown menu (using page attributes) that the user could pick a layout from and then use that field to preselect the regions that are activated for the user in the master page.

Jon