Quote from: myan24 at Feb 23, 2006, 01:25 AM
I want a child document to appear in a parent folder like this:
http://www.mysite.com/about/index.html
If I type the above, I get the file as expected. However, if I type the following:
http://www.mysite.com/about/
I get the template associated with the folder "about" which in this case happens to be blank (couldn’t select it to no template as I thought I might be able to). Should that be the case? Is there a way to get the index.html file to show up just by typing in the folder name, as above? Also, in the above example, the folder "about" has an ID of 5. I can get to the folder through the following also:
http://www.mysite.com/5.html
Should that be the case too? I don’t get how a folder can be a file?
Just think of folders as documents that can have children. They can also contain content, perhaps a summary of all the things in it or whatever else might be appropriate, accessible via several approaches (as you noticed).
To emulate a web server which is configured to look for an index.html page when the folder URL is provided, you can easily create a template to assign to your folders with just the following content:
<html><body>[!FolderIndex!]</body></html>
Then code a simple snippet called FolderIndex that looks for a child doc with the alias of index, something like this:
$children= $modx->getDocumentChildren($this->documentIdentifier, 1, 0, "id", "alias='index'", "", "", "1");
if (!isset ($children[0]['id']) || !$indexPageId= $children[0]['id']) {
return "<p>Directory browsing not allowed!</p>";
}
$modx->sendRedirect($modx->makeUrl($children[0]['id']));
That would emulate typical Apache directory behavior, and you can customize that however you want from there. There are probably many other ways to approach this, for instance a plugin that checks to see if the requested document is a folder type (i.e. has children), and decides what to do via any registered events, but I just wanted to give you an idea of how you can approach this in a MODx way.
There are other solutions similar to this in these forums as well, such as at this topic:
http://modxcms.com/forums/index.php/topic,1394.0.html