Forum

Thread tagged as: Problem, Error, Configuration

Master pages

Ok, getting into a pickle with Master Pages.

This is what I've done:

  1. Set up a content template in the /templates/content folder thus:
<div class="w-section heroimage indcasestudy">
    <div class="w-container intpgeconttext">
      <div class="intpgeherotext">Case Study: <perch:content id="casestudytitle" type="text" label="Case Study Title Title" required="true" order="1" /></div>
    </div>
  </div>
  <div class="w-section casestudylogosection">
    <div class="w-container cstudylogocont"><img class="casestudylogoimg" src="<perch:content type="image" id="casestudylogo" label="Case Study Logo" />" alt="<perch:content type="text" id="alt" label="Alt tag" required="true" help="Enter a description of this image" title="true" order="2" />" />
    </div>
  </div>
  <div class="w-section casestudyquote">
    <div class="w-container casestudyquotecont">
      <p class="casestudyquotep">"<perch:content id="casestudyquote" type="text" label="Case Study Quote" required="true" order="3" />"</p>
      <div class="casestudyquoteco"><perch:content id="clientcompanyname" type="text" label="Client Company Name" required="true" order="4" /></div>
    </div>
  </div>
  <div class="w-section aboutsection">
    <div class="w-container aboutcont intpage">
      <h1 class="casestudynumber first">Situation</h1>
      <p class="casestudyp"><perch:content id="situationtext" type="text" label="Sitation Text" required="true" order="5" /></p>
      <h1 class="casestudynumber">Approach</h1>
      <p class="casestudyp"><perch:content id="approachtext" type="text" label="Approach Text" required="true" order="6" /></p>
      <h1 class="casestudynumber">Outcome</h1>
      <p class="casestudyp"><perch:content id="outcome text" type="text" label="Outcome Text" required="true" order="7" /></p>
  1. I've set up a master page in the /templates/pages/ folder:
<?php include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php'); ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">


  <title></title>
<meta name="description" content="" />

<?php include('includes/head.php'); ?>
<body class="body">
<?php include('includes/headnav.php'); ?>


      <?php perch_content('Case Studies'); ?>


      <a class="hometextlink int" href="#">← Back to Clients</a>
    </div>
  </div>
<?php include('includes/foot.php'); ?>
  1. I think I'm correct in that I've set up an actual web-page called case-studies.php thus:
<?php include('perch/runtime.php'); ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">


  <title></title>
<meta name="description" content="" />

<?php include('includes/head.php'); ?>
<body class="body">
<?php include('includes/headnav.php'); ?>


      <?php perch_content('Case Studies'); ?>


      <a class="hometextlink int" href="#">← Back to Clients</a>
    </div>
  </div>
<?php include('includes/foot.php'); ?>

But when I go into Perch to set up a Master Page I get this error when trying choose a page to copy regions from:

Warning: str_repeat() [function.str-repeat]: Second argument has to be greater than or equal to 0 in /home/site/public_html/perch/core/apps/content/modes/template.edit.post.php on line 36
Andrew Areoff

Andrew Areoff 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I think I'm correct in that I've set up an actual web-page called case-studies.php

What's the purpose of this page?

So I don't need this? It's where I'm getting confused – do I only need the master page template thats in the /pages/ folder?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Well, I'm not sure if you need it or not - what is your intention and your goal?

I want to allow the client to add new pages and edit the content based on a master page.

Ok, I've deleted that page and it doesn't throw an error anymore.

But... when I go into Perch to Add a page it still asks me what choose from the list of templates. Can that be automated so it always uses the case study template I've created since I don't want my client to have to choose of course?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you can specify the region options in the master page:

https://docs.grabaperch.com/docs/developers/creating-regions/

This:

<?php perch_content_create('Case Studies', array( 'template' => 'casestudy.html', 'multiple' => true, 'edit-mode' => 'listdetail', 'sort' => 'date', 'sort-order' => 'DESC', )); ?>

to replace this:

<?php perch_content('Case Studies'); ?>

Is that correct? I don't understand the sort stuff as I just want it to use what's in the casestudy.html template file.

It;s working within Perch and I can add the page, the editable regions are now working automatically without specifying which template to use – good!

But when I view the page I've created in a browser, it doesn't contain any of the html I've put in my template.

It;s working within Perch and I can add the page, the editable regions are now working automatically without specifying which template to use – good!

But when I view the page I've created in a browser, it doesn't contain any of the html I've put in my template.

perch_content_create just creates the region to display it you will need to do this too

perch_content('Case Studies');

Andrew Areoff said:

It;s working within Perch and I can add the page, the editable regions are now working automatically without specifying which template to use – good!

But when I view the page I've created in a browser, it doesn't contain any of the html I've put in my template.

Andrew. See this post. I've just explained to another how content_create works.

https://forum.grabaperch.com/forum/10-01-2015-perch-content-create-with-the-regular-perch-tag

Thanks Robert! That works perfectly of course!

With lots of practice I could become just about competent at this!