Forum

Thread tagged as: Problem, Error, Configuration

php error when I check "This page will have more pages below it"

I can create a page without error, but when I check "This page will have more pages below it" I get a php error eg:

[Thu Apr 07 16:26:02.196219 2016] [:error] [pid 3600] [client 127.0.0.1:33681] PHP Fatal error: Call to undefined function perch_layout() in /var/www/html/kent/perch/templates/pages/default.php on line 2, referer: https://kent.new/perch/core/apps/content/page/edit/?id=59&created=true

The regions are not added and the file has this in it:

<?php include(str_replace('/', DIRECTORY_SEPARATOR, '../perch/templates/pages/intro.php')); ?>

If I create all pages without checking the option, I can edit the page, but I then tried to manually move them to a sub-folder and was unable to access them via the frontend - I get the white screen.

The site is hosted locally - here's my diagnostics:

Diagnostics report Health check

Perch is up to date
PHP 5.5.9-1ubuntu4.14 is up to date
MySQL 5.5.47-0ubuntu0.14.04.1 is up to date
Image processing available
File upload size is low. You can only upload files up to 2M.

Summary information

Perch: 2.8.28, PHP: 5.5.9-1ubuntu4.14, MySQL: 5.5.47, with PDO
Server OS: Linux, apache2handler
Installed apps: content (2.8.28), assets (2.8.28), categories (2.8.28)
App runtimes: <?php $apps_list = array( 'content', 'categories', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /var/www/html/kent/perch
PERCH_CORE: /var/www/html/kent/perch/core
PERCH_RESFILEPATH: /var/www/html/kent/perch/resources
Image manipulation: GD
PHP limits: Max upload 2M, Max POST 8M, Memory: 128M, Total max file upload: 2M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
HTTP_HOST: kent.new
DOCUMENT_ROOT: /var/www/html/kent/
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Raicheal Gallagher

Raicheal Gallagher 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What does the include line at the top of intro.php say?

<?php include('perch/runtime.php'); ?>

Drew McLellan

Drew McLellan 2638 points
Perch Support

That needs to be updated so that it's relative to the root of the site and can be used at any depth within the site structure.

Try this instead:

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

https://docs.grabaperch.com/docs/pages/master-pages/

The regions are now pulling into the pages and a sub-folder is being created - but viewing the page I'm getting a white screen with this error:

[Thu Apr 07 17:29:27.521798 2016] [:error] [pid 3600] [client 127.0.0.1:34239] PHP Fatal error: Call to undefined function perch_layout() in /var/www/html/kent/perch/templates/pages/default.php on line 2, referer: https://kent.new/perch/core/apps/content/edit/?id=41

Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you done the same for default.php ?

yes I added the missing "/" to all master pages. Also now I can't view any pages except the homepage.

my homepage index.php file is this:

<?php include('perch/runtime.php'); ?> <?php perch_layout('global.head'); ?> <?php perch_layout('global.header'); ?> <?php perch_content('Article'); ?> <?php perch_layout('global.footer'); ?> </body> </html>

If I add the leading "/" it white screens

if I make the runtime path absolute <?php include('/var/www/html/kent/perch/runtime.php'); ?> it appears to work

Drew McLellan

Drew McLellan 2638 points
Perch Support

Right, that's essentially what $_SERVER['DOCUMENT_ROOT'] is doing.

Aaaaah my apologies, I didn't implement your solution properly. Sorry, but my head is now officially mince.