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?
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?
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:
Here is the template set up for perch/templates/pages/en/en_home_page_template.php'
Here is my diagnostics:
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
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.
The log file suggests that it's the page 'template file' that's not being found, rather than the 'page'
Kim, can you show us the code on the test.php file? It should be a single line of code, something like:
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:
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.
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)
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.
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:
If I manually adjust the path to perch to include ../perch I get the page and all its contents to resolve properly.
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:
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.
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
Go back into perch admin
When I look at the page (en/index.php) in my editor the path perch is setting for the master template shows as:
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:
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.
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.