Forum
php includes break using PerchSystem::use_error_page(404) in Runway 3
The 404 error page template (perch/templates/pages/errors/404.php) works fine with standard php includes on normal 404s, but nothing is output when called by PerchSystem::use_error_page(404) - I'm trying to output the 404 page when there is no match for the slug on one of the Runway routes.
This is the 404.php:
include($_SERVER['DOCUMENT_ROOT'].'/inc/header.inc.php');
perch_content('Error description');
include($_SERVER['DOCUMENT_ROOT'].'/inc/footer.inc.php');
Any idea how to get included file to work here? Many thanks in advance.
Summary information
Perch Runway: 3.0.4, PHP: 5.6.28, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (3.0.4), assets (3.0.4), categories (3.0.4), perch_blog (5.5.1), perch_forms (1.9)
App runtimes: <?php $apps_list = [ 'perch_blog', 'perch_forms', ];
PERCH_LOGINPATH: /perch
PERCH_PATH: /Users/adam/Sites/hiddenireland.com/site/perch
PERCH_CORE: /Users/adam/Sites/hiddenireland.com/site/perch/core
PERCH_RESFILEPATH: /Users/adam/Sites/hiddenireland.com/site/perch/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
Resource folder writeable: Yes
HTTP_HOST: hiddenireland.dev
DOCUMENT_ROOT: /Users/adam/Sites/hiddenireland.com/site
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Where are you calling
PerchSystem::use_error_page(404)
?Why the
exit
?The code above is inside an if statement, so if I remove the exit statement, other content & php includes are output below. It runs at the top of every page template to process meta content; if no memberslug items are matched, there's no need to process meta content - I just want to output the 404 page, but the 404 page content only renders if I remove the php includes from the 404 page template.
Here's a bit more context - this is process-meta.php, included at the top of each page template:
With the exit statement, everything stops. That includes generating a 404.
I think you just need to rethink your page logic.
Thanks Drew, all working now after restructuring includes and clearing up the logic - hidden includes within includes!