Concrete can't find single page in application folder
Permalink
Hi. I'm trying to add a single page to my site under sitename.com/index.php/singlepagetest. Documentation clearly says to put a php file inside application/single_pages directory yet when I do this navigating to this page results in an error message include(/PATH_TO_CONCRETE/www/concrete/single_pages/singlepagetest.php): failed to open stream: No such file or directory
So it appears it is looking inside concrete directory instead of application? If I put the file inside concrete/single_pages everything works fine.
So it appears it is looking inside concrete directory instead of application? If I put the file inside concrete/single_pages everything works fine.
After you put the page into the single_pages directory, did you go to the Dashboard -> Pages & Themes -> Single Pages and add your single page to the list?
Yes, I did and it was added into the list of single pages. I can also see a corresponding record in Pages table in DB.
What does the namespace at the top of your file look like? It should be
If it wasn't that, or you don't have a namespace you need that and you will need to "refresh" your single page in the dashboard.
namespace Application\SinglePages;
If it wasn't that, or you don't have a namespace you need that and you will need to "refresh" your single page in the dashboard.
Looks like adding namespace and refreshing page in the list changes nothing, the error still persists. I've also cleared the cache from the dashboard and logged out.
So you have a file named singlepagetest.php it the /application/single_pages directory, you have added singlepagetest to the Single Pages dashboard page, you have the namespace "namespace Application\SinglePages;" in your /application/single_pages/singlepagetest.php at the very top of the file, and you have cleared the cache?
Yes, I've checked all these points once again and the error is still there. If, however, the same file is put into concrete/single_pages folder page functions correctly.
That file should not work in the /concrete directory if the namespace is correct.
<?php
namespace Application\SinglePages;
echo "printing this out of /NetBeansProjects/Ocms/www/concrete/single_pages/singlepagetest.php ";
This is verbatim the file that is located at /concrete/single_pages/, upon accessing mydomain.dev/index.php/singlepagetest I see the output, removing or renaming this file results in an error
namespace Application\SinglePages;
echo "printing this out of /NetBeansProjects/Ocms/www/concrete/single_pages/singlepagetest.php ";
This is verbatim the file that is located at /concrete/single_pages/, upon accessing mydomain.dev/index.php/singlepagetest I see the output, removing or renaming this file results in an error
I've managed to track down the source of the problem inside the CMS itself, inside the src/Foundation/Environment.php. Inside the method getRecord, where apparently overrides for resources are processed, $this->coreOverrides contains paths towards resources that are absolute (i.e. starting with /var/www...), meanwhile $segment contains relative paths which prevents the method from discovering that given segment is, in fact, contained in $this->coreOverrides. Patching the method so it appends DIR_APPLICATION in front of $segment when searching inside $this->coreOverrides solves the problem and CMS loads singlepagetest.php from the application folder like it's supposed to, yet it's unclear whether this is caused by some misconfiguration or is this a genuine bug?