Forum

Thread tagged as: Problem, Error

perch moving pages is not working

I have a multi-language set up using the example in option 1 that is outlined on the perch website. I am having trouble getting pages to display if they are not in the root directory.

structure: root(dev.domain.com) en/ es/ fr/

When I create a page I create it in the root directory and then choose page options and place the directory in front of the file name and select move file to this location. (IE en/test.php) Even though it says the file is moved when I try to preview it I get the following 404 error when previewing: The requested URL /perch/core/apps/content/page/en/test.php was not found on this server.

After this, cannot move it back to the root. I get the following error in perch: No page file exists at that location to move.

What is the expected result? I saw a forum post about moving pages within perch, but it's not functioning properly for me. What am I missing?

Kim Mazzola

Kim Mazzola 0 points

  • 4 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

You need to have a forward slash in front of /en

/en/test.php

not

en/test.php

As the error shows the file is trying to be found within the Perch Admin area, which is because you have given a relative path.

Unfortunately I forgot to mention in my original post that I have tried it both with the forward slash and without and get the same results. Any other suggestions?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

I'd need some more information. In the information you have given us the 404 you have is because you have located the page relative to the Perch Control Panel, which isn't going to work.

There are troubleshooting tips including information about how to provide info that will get you an answer quickly in this post: https://docs.grabaperch.com/perch/help/

Rachel,

It seems the page is being created if I set the path at creation. However, viewing the page (with content created on the page) gives me a blank page. Below are the log report, template set up and diagnostics.

If I create a page set the path to /en/page.php at creation, the page is created and placed in the correct directory, but I get a blank display when trying to view it.

If I create a page at the root level /page.php the content is visible. If I move the page to /en/page.php perch tells me the page has been moved. I view the page and once again that same page that worked seconds ago is blank. Move it back to the root /page.php and all the content shows.

Here is the PHP error in my logs:

[10-Feb-2017 10:42:41 America/New_York] PHP Warning:  include(perch/templates/pages/en/en_home_page_template.php): failed to open stream: No such file or directory in /Volumes/OWC_Work_files/work/PHP-Sites/dev.edwardlimo/en/test-root.php on line 1
[10-Feb-2017 10:42:41 America/New_York] PHP Warning:  include(): Failed opening 'perch/templates/pages/en/en_home_page_template.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php7.0.0/lib/php') in /Volumes/OWC_Work_files/work/PHP-Sites/dev.edwardlimo/en/test-root.php on line 1

Here is the template set up for perch/templates/pages/en/en_home_page_template.php'

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


<section id="header">
    <?php 
        perch_pages_navigation(array(
            'template' => array('en/level1.html', 'en/level2.html'),
        ));
    ?>
</section>

<?php 
    perch_content_create('Carousel', array(
        'template' => 'carousel/carousel_main.html',
        'multiple' => true,
    )); 
?>
<?php
    perch_content_custom('Carousel', array(
        'template' => 'carousel/carousel_indicators.html',
    ));
?>
<?php
    perch_content_custom('Carousel', array(
        'template' => 'carousel/carousel_slides.html',
    )); 
?>                  

    <?php perch_content('Page Content Sections'); ?>       

   <?php perch_layout('en_global.footer'); ?>

Here is my diagnostics:

Perch: 2.8.34
Production mode: Production (100)
Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34), perch_forms (1.8.3)
DB driver: PDO
DB tables: perch2_categories (0), perch2_category_counts (0), perch2_category_sets (0), perch2_content_index (150), perch2_content_items (29), perch2_content_regions (8), perch2_forms (0), perch2_forms_responses (0), perch2_navigation (0), perch2_navigation_pages (0), perch2_page_templates (9), perch2_pages (1), perch2_resource_log (14), perch2_resource_tags (0), perch2_resources (9), perch2_resources_to_tags (0), perch2_settings (17), perch2_user_passwords (0), perch2_user_privileges (29), perch2_user_role_privileges (16), perch2_user_roles (2), perch2_users (1)
Users: 1
PHPMailer: 5.2.21
App runtimes:
<?php
    $apps_list = array(
        'content', 
        'categories',
        'perch_forms',
    );
?>
Editor plug-ins: markitup
H1: 5ad5f90e70766c209e35a522222c327b
L1: ce898dca655f7d5d47b5e4cd1445253b
F1: 6a33f95eca3667f9e0c39bf5ca2980fe
headerColour: #ffffff
content_singlePageEdit: 0
helpURL:
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
update_2.8.34: done
latest_version: 2.8.15
on_sale_version: 2.8.34
headerScheme: light
content_hideNonEditableRegions: 1
dashboard: 1
hide_pwd_reset: 0
content_frontend_edit: 0
logoPath: /perch/resources/edward-limousines-logo-web.jpg
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_DB_USERNAME: root
PERCH_DB_SERVER: localhost
PERCH_DB_DATABASE: edward_limo
PERCH_DB_PREFIX: perch2_
PERCH_TZ: UTC
PERCH_EMAIL_FROM: kmm@innersitedesign.com
PERCH_EMAIL_FROM_NAME: Kim Mazzola
PERCH_LOGINPATH: /perch
PERCH_PATH: /Volumes/OWC_Work_files/work/PHP-Sites/dev.edwardlimo/perch
PERCH_CORE: /Volumes/OWC_Work_files/work/PHP-Sites/dev.edwardlimo/perch/core
PERCH_RESFILEPATH: /Volumes/OWC_Work_files/work/PHP-Sites/dev.edwardlimo/perch/resources
PERCH_RESPATH: /perch/resources
PERCH_HTML5: 1
PERCH_RUNWAY:
PERCH_ERROR_MODE: DIE
PERCH_DATE_LONG: %d %B %Y
PERCH_DATE_SHORT: %d %b %Y
PERCH_TIME_SHORT: %H:%M
PERCH_TIME_LONG: %H:%M:%S
PERCH_RUNWAY_ROUTED:
PERCH_STRONG_PASSWORDS:
PERCH_DEBUG:
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: /Volumes/OWC_Work_files/work/PHP-Sites/dev.edwardlimo/perch/templates
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_PRODUCTION_MODE: 100
PERCH_RWD:
PERCH_HTML_ENTITIES:
PERCH_SSL:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_PARANOID:
PERCH_FORCE_SECURE_COOKIES:
PERCH_PASSWORD_MIN_LENGTH: 6
PERCH_MAX_FAILED_LOGINS: 10
PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR
PERCH_VERIFY_UPLOADS:
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
PERCH_SESSION_TIMEOUT_MINS: 20
HOSTING SETTINGS

PHP: 7.0.0
Zend: 3.0.0
OS: Darwin
SAPI: apache2handler
Safe mode: not detected
MySQL client: mysqlnd 5.0.12-dev - 20150407 - $Id: 7e72f9690b1498a1bead7a637c33a831c0d2f655 $
MySQL server: 5.5.42
Free disk space: 287.16 GB
Extensions: Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dom, hash, fileinfo, filter, ftp, gd, SPL, iconv, intl, json, ldap, mbstring, session, standard, mysqlnd, PDO, pdo_mysql, pdo_sqlite, Phar, posix, Reflection, mysqli, SimpleXML, soap, sockets, exif, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, zip, apache2handler, imap, mcrypt, pgsql, pdo_pgsql
GD: Yes
ImageMagick: No
PHP max upload size: 32M
PHP max form post size: 32M
PHP memory limit: 128M
Total max uploadable file size: 32M
Resource folder writeable: Yes
Session timeout: 24 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: Yes
HTTP_HOST: dev.edwardlimousines.com:9008
HTTP_ACCEPT_ENCODING: gzip, deflate
HTTP_COOKIE: cmsa=1; PHPSESSID=04584359f6f4250c138c6fff35eca919
HTTP_CONNECTION: keep-alive
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8
HTTP_REFERER: https://dev.edwardlimousines.com:9008/perch/core/settings/diagnostics/
HTTP_DNT: 1
HTTP_ACCEPT_LANGUAGE: en-us
PATH: /usr/bin:/bin:/usr/sbin:/sbin
SERVER_SOFTWARE: Apache
SERVER_NAME: dev.edwardlimousines.com
SERVER_ADDR: ::1
SERVER_PORT: 9008
REMOTE_ADDR: ::1
DOCUMENT_ROOT: /Volumes/OWC_Work_files/work/PHP-Sites/dev.edwardlimo
SERVER_ADMIN: you@example.com
SCRIPT_FILENAME: /Volumes/OWC_Work_files/work/PHP-Sites/dev.edwardlimo/perch/core/settings/diagnostics/index.php
REMOTE_PORT: 62806
GATEWAY_INTERFACE: CGI/1.1
SERVER_PROTOCOL: HTTP/1.1
REQUEST_METHOD: GET
QUERY_STRING: extended
REQUEST_URI: /perch/core/settings/diagnostics/?extended
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
PHP_SELF: /perch/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1486740951.48
REQUEST_TIME: 1486740951
argc: 1

Drew McLellan

Drew McLellan 2638 points
Perch Support

What happens if you try to create the page in the correct place to begin with, rather than creating it in the root and moving it?

Sorry, perhaps I wasn't clear. I did give these details in my last response. I'm sorry if it wasn't clear.

The page is created, but when viewed shows as blank. Move that page to the root and all the content is visible.

here is the latest PHP error log output

[10-Feb-2017 13:44:41 America/New_York] PHP Warning:  include(perch/templates/pages/en/en_home_page_template.php): failed to open stream: No such file or directory in /Volumes/OWC_Work_files/work/PHP-Sites/dev.edwardlimo/en/page.php on line 1
[10-Feb-2017 13:44:41 America/New_York] PHP Warning:  include(): Failed opening 'perch/templates/pages/en/en_home_page_template.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php7.0.0/lib/php') in /Volumes/OWC_Work_files/work/PHP-Sites/dev.edwardlimo/en/page.php on line 1
[10-Feb-2017 13:45:42 America/New_York] PHP Warning:  include(perch/templates/pages/en/en_home_page_template.php): failed to open stream: No such file or directory in /Volumes/OWC_Work_files/work/PHP-Sites/dev.edwardlimo/en/page.php on line 1
[10-Feb-2017 13:45:42 America/New_York] PHP Warning:  include(): Failed opening 'perch/templates/pages/en/en_home_page_template.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php7.0.0/lib/php') in /Volumes/OWC_Work_files/work/PHP-Sites/dev.edwardlimo/en/page.php on line 1

Drew McLellan

Drew McLellan 2638 points
Perch Support

So the database entry for the page is created, but the page itself isn't?

The database entry is created. The page is created, I can add content to the regions. If I move the page to the root directory (root/page.php) the HTML is output and I can view the page. If I place the page a subdirectory (IE: root/en/page.php) I get a blank page returned.

The database does record the update on the page path each time I move the page.

Simon Clay

Simon Clay 127 points

The log file suggests that it's the page 'template file' that's not being found, rather than the 'page'

PHP Warning: include(perch/templates/pages/en/en_home_page_template.php): failed to open stream: No such file or directory

Kim, can you show us the code on the test.php file? It should be a single line of code, something like:

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

Simon,

Thank you for stepping in to help! It's greatly appreciated.

The templates are there. If the template file couldn't be found than I would get a blank page at root level as well as the sub-directory. All pages created and left in the root directory work perfectly. It's only when the page is moved to the sub-directory that creates an issue. Here is what the code is on the pages (both at root level and in the subdirectory:

Local set up testing below:

ROOT LEVEL : <?php include(str_replace('/', DIRECTORY_SEPARATOR, 'perch/templates/pages/en/en_home_page_template.php')); ?>

SUB-DIRECTORY : <?php include(str_replace('/', DIRECTORY_SEPARATOR, 'perch/templates/pages/en/en_home_page_template.php')); ?>

When I place everything on my remote development server I get the following error on the page in the sub-directory which makes me think the set up with the template is not starting at the root even though the call to the template uses the back slash.

Warning: include(/perch/templates/pages/en/en_home_page_template.php): failed to open stream: No such file or directory in /home/rckmm/public_html/edwardqualitylimos/en/test-en.php on line 1

Warning: include(): Failed opening '/perch/templates/pages/en/en_home_page_template.php' for inclusion (include_path='.:/opt/php54/lib/php') in /home/rckmm/public_html/edwardqualitylimos/en/test-en.php on line 1

So, I manually changed the call to the template as follows and the page resolved. Which now let's me know that the root call is not being recognized. How can I fix this? Is there something missing in my original call? Did I make a mistake when creating the sub-directories on the root level? I created 3 directories under the root (root/en, root/es, root/fr)

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

Drew McLellan

Drew McLellan 2638 points
Perch Support

What setting do you have for the sub-page folder setting for your /en/index.php file?

I haven't created an index file yet (don't know if that's relevant so I wanted to mention it), but I have created test files. So, if you are referring to the setting in perch, I have used the starting forward slash /en/page.php.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, it might be a good idea to create that page.

Good Morning Drew,

I'm assuming you want me to use a master page, create a page and save it to the /en directory, correct?

So, I did that. I created an index page in the /en directory. I filled it with content and saved it to the /en/index.php and received the same results. No content is output.

As soon as I reset the path to /index.php and tell perch to move the page to this directory, the page content is visible.

I get the same results on my localhost setup, and my remote testing server. Locally, I am on mac using MAMP PRO.

Here is the code that is produced on the index.php page:

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

If I manually adjust the path to perch to include ../perch I get the page and all its contents to resolve properly.

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

And just in case this is helpful, here is the master template code. I have created 3 directories in content/pages/ for different language templates. So in the en/ directory I have this template:

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


<section id="header">
    <?php 
        perch_pages_navigation(array(
            'template' => array('en/level1.html', 'en/level2.html'),
        ));
    ?>
</section>

<?php 
    perch_content_create('Carousel', array(
        'template' => 'carousel/carousel_main.html',
        'multiple' => true,
    )); 
?>
<?php
    perch_content_custom('Carousel', array(
        'template' => 'carousel/carousel_indicators.html',
    ));
?>
<?php
    perch_content_custom('Carousel', array(
        'template' => 'carousel/carousel_slides.html',
    )); 
?>                  

    <?php perch_content('Page Content Sections'); ?>       

   <?php perch_layout('en_global.footer'); ?>

Any help with a solution here? I created an index page and still get the same results. It doesn't resolve when placed in a sub-folder. Please help, I can't get this site built without solving this issue. Thank you.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'm really not clear on what the problem is. When you create a page, where does the file get created, and where should it get created?

I'm not really sure how to better explain it. Steps to create a page:

In perch admin

  1. Add page
  2. choose master template (pages/en/en_home_page_template.php)
  3. save the page to /en/index.php directory -- check the box move the page to this location. (updates successfully and I see the page in the en/ directory)
  4. Set my templates to use on the regions.
  5. Fill the regions with content.
  6. View the page in a browser at https://dev.domain.com/en/index.php The page is BLANK. (No HTML is written at all)

Go back into perch admin

  1. Click on the page
  2. click on page options
  3. change the path to /index.php (move it to the root directory)
  4. check the box for "move page to this location" it updates successfully and I see the page moved.
  5. View the page in a browser at https://dev.domain.com/index.php All the content that was just blank when the page is in the en/ directory is now VISIBLE. All HTML is working perfectly to display the contents on the page.

When I look at the page (en/index.php) in my editor the path perch is setting for the master template shows as:

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

Notice no forward slash or trailing .../ before the call to perch. THAT page is BLANK when viewed in a browser.

If I open the en/index.php in my editor and change the path to perch to the following:

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

Notice the addition of the "../" before the perch directory, the page shows all the content and is not blank. So, it appears the root relative link to the perch folder and templates is not working. It has to be a relative path in order for the page to resolve. I tested on my remote development server and my localhost set up and get the same results on both servers.

I can't manually update the link to perch on all the pages created because then the end user won't be able to add pages as will unless I go in and update the link to perch.

How can I get this to work?

Any updates? I've explained my situation as well as I can. It's rather frustrating when you follow the directions in the perch docs and hit a road block such as this. Does anyone know why this is happening? See my last post before this one for an in-depth description of my problem.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you able to reproduce this on a clean slate?

I just tried using the default template and creating a page and it works. I don't have any code added to your default template that ships with perch.