Forum

Thread tagged as: Problem, Error

Create pages from master page

I am very new to perch and I'm getting extremely frustrated with not being able to figure this out. Perhaps I don't understand how this works? I thought people could create pages on the fly based on a template. But it seems to me that the page has to exist first for perch to recognize it. How can new pages be added on the fly to a live site if that is the case?

I want the editor to be able to create pages from a master page. I have done the following:

1 - created a master page with perch regions

    <?php include('perch/runtime.php'); ?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title><?php perch_pages_title(); ?></title>
    <?php perch_page_attributes(array(
    'template'=>'default.html'
    ));
?>
<!-- Bootstrap core CSS -->
    <link href="../../../css/bootstrap.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="../../../css/styles.css" rel="stylesheet">
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
      <script src="js/respond.min.js"></script>
    <![endif]-->    
    <!-- Custom styles for the parallax -->
    <link href="../../../css/demo.css" rel="stylesheet">
     <script src="js/demo.js"></script>      
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
        <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="../../../js/jquery.min.js"></script>
        <script src="../../../js/bootstrap.min.js"></script>
        <script src="../../../js/jquery.validate.js"></script>
</head>            
 <section class="module parallaxTop parallax-1"></section> 
<section class="light_section content">
    <div class="container">
        <div class="row">
            <div class="col-sm-10 col-sm-offset-1">
             <?php perch_content('Top Intro'); ?>
            </div>
          </div><!-- ./row -->
     </div><!-- ./container -->           
</section>
 <section class="module parallax parallax-4">
      </section> 
<section class="black_section content">
    <?php perch_content_create('new page', array( 
    'template' => 'new-page.html' 
      )); ?>
</section>
<section id="footerContent" class="black">
<footer>
this contains straight HTML
</footer>
</section>
 </body>
 </html>
    ~~~   
2 - the templates are in the perch > content directory. The code for the new-page.html template is created with blocks:
<perch:blocks>
<perch:block label="Text" type="SingleLineText">
    <perch:template path="content/text.html" />
</perch:block>

<perch:block label="2 Columns text with images" type="cols2text">
    <perch:template path="content/2cols.html" />
</perch:block>

<perch:block label="3 Columns text with images" type="cols3text">
    <perch:template path="content/3cols.html" />
</perch:block>

<perch:block label="4 Columns text with images" type="cols4text">
    <perch:template path="content/4cols.html" />
</perch:block>

<perch:block label="3 Boxes with Blue Border (home page featured)" type="cols3boxes">
    <perch:template path="content/home-boxes.html" />
</perch:block>
<perch:block label="Text Block" type="TextBlock">
    <perch:template path="content/text_block.html" />
</perch:block> 

</perch:blocks> ~~~

3 - I log into the CMS, set up my master page as follows: Don not copy the regions, reference this master page.

4 - I view my pages listing. Click add new page, set up the page to use the master page and then save it.

My problems 1 - when trying to view the new page I either get a 404 page can't be found, or I get a BLANK page. I set up debugging, but that doesn't populate either so I can't see anything. My blocks region does not get loaded in the CMS and I can't add content.

2 - if I change the path to the page to include /folder/page.php I get a 404 page can't be found.

3 - Checking the DB I do see the new page listed in the page table.

Kim Mazzola

Kim Mazzola 0 points

  • 5 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Can you post your Diagnostics Report please?

If you are getting a blank page then you have a PHP error. What does your error log say?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

We also have a video detailing how you create new pages in Perch: https://docs.grabaperch.com/video/v/creating-pages/

Thank you Rachel for your reply. I am working locally before uploading the finished site to a live server. Here's my diagnostics report. I am developing on mac with mamp. I have watched the video several times and read through the docs as well. I just can't seem to grasp what I'm doing wrong.

I seem to be having a few odd behaviors. Perch keeps creating subpages under my top level pages while I am working on templates. I am constantly having to delete sub pages. Creating a new page and setting it as top level and then checking again shows it was set to have "home" as the parent page. I reset it, and still get the same results.

I can send screenshots as well.

~~~Perch: 2.8.25, PHP: 5.6.2, MySQL: 5.5.38, with PDO Server OS: Darwin, apache2handler Installed apps: content (2.8.25), assets (2.8.25), categories (2.8.25) App runtimes: <?php $apps_list = array( 'content', 'categories', ); PERCH_LOGINPATH: /diamondTransportation/perch PERCH_PATH: /Volumes/OWC_Work_files/work/PHP-Sites/diamondTransportation/perch PERCH_CORE: /Volumes/OWC_Work_files/work/PHP-Sites/diamondTransportation/perch/core PERCH_RESFILEPATH: /Volumes/OWC_Work_files/work/PHP-Sites/diamondTransportation/perch/resources Image manipulation: GD PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M F1: dc1fef2ad0fcd9f943c02ebb43d85dbc Resource folder writeable: Yes HTTP_HOST: localhost:8888 DOCUMENT_ROOT: /Volumes/OWC_Work_files/work/PHP-Sites REQUEST_URI: /diamondTransportation/perch/core/settings/diagnostics/ SCRIPT_NAME: /diamondTransportation/perch/core/settings/diagnostics/index.php ~~~

Here is a screenshot of the pages being added at random as I work. These appeared as I was replying to you and went into the CMS to get the diagnostics report.

odd pages added

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Those URLs look like something on your page is generating weird URLs, which Perch will see as a new page. They certainly don't come from Perch. Do you have some JavaScript running for example?

We also need to see your error log. Mamp will produce a PHP error log, what is in it when you get the "blank page"?

I created a new page and here is the PHP error log: ~~~ [12-Feb-2016 16:10:25 Europe/Berlin] PHP Warning: include(perch/runtime.php): failed to open stream: No such file or directory in /Volumes/OWC_Work_files/work/PHP-Sites/diamondtransportation/perch/templates/pages/Interior_free_form.php on line 1 [12-Feb-2016 16:10:25 Europe/Berlin] PHP Warning: include(): Failed opening 'perch/runtime.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.6.2/lib/php') in /Volumes/OWC_Work_files/work/PHP-Sites/diamondtransportation/perch/templates/pages/Interior_free_form.php on line 1 [12-Feb-2016 16:10:25 Europe/Berlin] PHP Fatal error: Call to undefined function perch_pages_title() in /Volumes/OWC_Work_files/work/PHP-Sites/diamondtransportation/perch/templates/pages/Interior_free_form.php on line 6 [12-Feb-2016 16:11:30 Europe/Berlin] PHP Warning: include(perch/runtime.php): failed to open stream: No such file or directory in /Volumes/OWC_Work_files/work/PHP-Sites/diamondTransportation/perch/templates/pages/Interior_free_form_38CJB2FWV6.php on line 1 [12-Feb-2016 16:11:30 Europe/Berlin] PHP Warning: include(): Failed opening 'perch/runtime.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.6.2/lib/php') in /Volumes/OWC_Work_files/work/PHP-Sites/diamondTransportation/perch/templates/pages/Interior_free_form_38CJB2FWV6.php on line 1 [12-Feb-2016 16:11:30 Europe/Berlin] PHP Fatal error: Call to undefined function perch_pages_title() in /Volumes/OWC_Work_files/work/PHP-Sites/diamondTransportation/perch/templates/pages/Interior_free_form_38CJB2FWV6.php on line 6 ~~~

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Your path to the Perch runtime is incorrect.

Failed opening 'perch/runtime.php' for inclusion

Make sure you use the runtime include as detailed in our documentation (and in the video) https://docs.grabaperch.com/docs/pages/master-pages/

I am so sorry for being such trouble. The little bit I have accomplished with Perch is wonderful. Just wish I could get it to create new pages on the fly using blocks. This way the site would be complete.

I wish I could say that solved it. In addition, overtime I open a file in my HTML editor perch creates another file in the CMS using the page I open and adds that weird string onto the URL. Could this have anything to do with the setup of my "PHP Sites" folder? It's outside of MAMP on an external drive. But MAMP is mapped to use that drive.

Perch says the page is created and lists it in pages. But when I view my site directory, no page has been created.

Trying to make a new page here is the error from map. the path to perch is set in my Interior_free_form.php as follows:

<?php include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php'); ?>

[12-Feb-2016 19:27:53 Europe/Berlin] PHP Warning: include(/Volumes/OWC_Work_files/work/PHP-Sites/perch/runtime.php): failed to open stream: No such file or directory in /Volumes/OWC_Work_files/work/PHP-Sites/diamondtransportation/perch/templates/pages/Interior_free_form.php on line 1 [12-Feb-2016 19:27:53 Europe/Berlin] PHP Warning: include(): Failed opening '/Volumes/OWC_Work_files/work/PHP-Sites/perch/runtime.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.6.2/lib/php') in /Volumes/OWC_Work_files/work/PHP-Sites/diamondtransportation/perch/templates/pages/Interior_free_form.php on line 1 [12-Feb-2016 19:27:53 Europe/Berlin] PHP Fatal error: Call to undefined function perch_layout() in /Volumes/OWC_Work_files/work/PHP-Sites/diamondtransportation/perch/templates/pages/Interior_free_form.php on line 3

Drew McLellan

Drew McLellan 2638 points
Perch Support

I open a file in my HTML editor perch creates another file in the CMS using the page I open and adds that weird string onto the URL.

Can you give an example of this? Which editor are you using?

Drew,

I'm using Dreamweaver strictly as an editor. I also have brackets to use. The issues seem to arise from a "path issue". However, in your setup instructions I don't see anything that says don't develop in a folder under your local host. Create a new host for every site you develop. If I am missing that, please point it out.

After much research and googling I have found this article that would be wonderful to know from the start. I also found a quite a few posts through google in your forum talking about the same issues I'm experiencing. Perhaps there is quite a need to allow perch to write to the folder that has been set up as the root in the development environment? If that were allowed, my setup would have transferred to the live site easily.

So, realizing it's a path issue I set up a dev.mydomain.com on my remote staging server. Because it's not a live domain you can only access it via IP After creating the DB, updating my config and loading everything I see my images are not working. I tried to log into perch and naturally it can't be found because it defaults to the IP address and not the IP/~foldername/perch Click on any of the pages and it defaults to the IP address. What am I missing??

I know it's a path issue from a forum user here, so I set the path to perch with the IP/~foldername/perch to log into perch to fix that and I get a message that my license is not valid for this domain. I logged into my perch account here, added the staging server to the license and still cannot log in.

On top of all this, since I had to set my config file with the path to perch with the IP/~foldername/perch when I do finally get this moved to the live domain will I have to run through all of this once again?

I realize now I shouldn't have developed the site using MAMP and my local folder with all my sites, but now I can't even log into the dev set up.

I have to say, making templates, adding layouts, making content dynamic with perch is great, the steps to set up could be a bit more clear for people that are not true PHP programmers. I am so very frustrated with this at the moment, as I'm sure you can tell.

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you're accessing the site via an IP address and a subfolder, then that's no different from being in a subfolder on your local machine with MAMP. So you're no better off there - you need to point your dev.mydomain.com domain at it and access the site with that.

I'm confused. I used my client's domain name. I set up dev.myclientdomainname.com on my staging server. I don't have a domain to point to that. So, yes I know I'm no better off. If you have a better way for me to accomplish this, please let me know. Other than developing on their live server and taking down their current site, I don't know how to accomplish this.

I wanted to report back that after many, many, many hours (days actually) of frustration with this, I was finally able to get this working under a localhost at root level using MAMP PRO and can see the pages created as I make them. If you want someone to write a beginners manual with all the possible mistakes that can be made, I'm your writer. ;-)

Now to figure out how to add classes to a section and let my user set the class on a section. EX section class="a list of classes" ... is there a help video or tutorial for that?

Thank you.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What is a 'section' for you? A page, a region, something else?

Sorry for the ambiguity. I should have been more clear in asking.

I have several HTML sections on the pages. A sample of code is `<section class="dark_section" id="idname"> HTML/CSS </section>

<section class="parallax"> </section>`

So the sections can be assigned a class. dark_section obviously gives it a dark background color while parallax allows for a large background image. light_section give a light colored background. I would like to create a template for each and make them a region available on a page using blocks. Which, btw are amazing once I got this working. I'm really enjoying blocks.

While I'm asking, since parallax set up uses background images set in CSS is there any work around that perch offers for that?

Thank you.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You'd do something like this in your template

<section class="<perch:content label="Class" id="class" type="select" options="dark_section, parallax" />">
...
</section>

Thank you. I did see that for the body tag and was going to give that a try. I appreciate the help.