kolber / stacey

Cheap & easy content management
http://staceyapp.com
MIT License
1.04k stars 131 forks source link

"Templated" content not working properlly at root level #75

Open andremalenfant opened 11 years ago

andremalenfant commented 11 years ago

Any content folder that is under the root directory does not work properly since the root_path is not defined correctly.

Suppose the following structure:

content/01.FolderA/01.SubFolderX/ content/01.FolderA/02.SubFolderY/ content/02.FolderB

Only the content in the "01.FolderA/" subfolders will work properly, the content directly in "02.FolderB" will not render correctly as the page is not properly initialized. This has the effect that /sitemap.xml or feed.xm, etc. does not work (only through /?/sitemap, etc.) or any kind of "templated" content.

I investigated and in stacey.inc.php, function __construct($get), at line 128, there is the following code:

if (!preg_match('/\//', $key)) $key = false;

At this point, it is certain that the path will not contain any slashes as the directory is directly under the root and the URI will be "/02.FolderB" (using the above example) and leading and trailing slashes have been removed previously. Thus, $key = "02.FolderB" and line 128 will essentially set $key to false and the page will not be initialized correctly. There is the intention to set $key to index below but this does not work as isset($key) returns true (since $=false and not NULL) anyways and an empty path is passed to the initializing function. Properly setting to "index" for this path would obviously not do the job either...

I don't have the big picture and there must be a reason for that line. But, for now, I have commented line 128 on my install as it fixes my problems and does not create adverse effects for me. I have seen similar issues on github that could be related.

kolber commented 11 years ago

That is strange, the leading and trailing slashes should not be removed until after line 128 (on the very next line in fact). Is your stacey.inc.php file out of date perhaps?