I am using the [!FirstChild!] snippet and works great - below is the script.
But have a request...
First, I am using friendly URL’s.
I use many folders on my site. Each of these folders have an ’index.html’ page, along with other pages. The ’index.html’ page is not always the "firstchild" - so how can I have the script look for the alias ’index.html’ instead?
Regards,
Ken
-----------------------------
if (!isset($id)) $id=$modx->documentIdentifier;
$children=$modx->getActiveChildren($id,’menuindex’,’ASC’);
if (!$children===false)
{
$firstChild = $children[0];
$firstChildUrl = $modx->makeUrl($firstChild[’id’]);
}
else
{
$firstChildUrl = $modx->makeUrl($modx->config[’site_start’]);
}
return $modx->sendRedirect($firstChildUrl);
-----------------------------
test it (if use sufix like html and the alias is index else change alias="index"to alias="index.html")
if (!isset($id)) $id=$modx->documentIdentifier;
$children = $modx->getDocumentChildren($id,1,0,’id,alias’, ’alias="index"’,’pagetitle’, ’DESC’);
$childrenCount = count($children);
if (!$children===false)
{
$firstChild = $children[0][’id’];
$firstChildUrl = $modx->makeUrl($children[0][’id’]);
}
else
{
$firstChildUrl = $modx->makeUrl($modx->config[’site_start’]);
}
return $modx->sendRedirect($firstChildUrl);
a little error fixed test it now (change the upper code)
the problem whith this snippets are all folders need a index page....
this could be used in the template and only redirects if has the page a subpage whith the alias index if not dont redirect and you dont need to use the snippet in all folders siply put in the template
hi
test it (if use sufix like html and the alias is index else change alias="index"to alias="index.html")
if (!isset($id)) $id=$modx->documentIdentifier;
$children = $modx->getDocumentChildren($id,1,0,’id,alias’, ’alias="index"’,’pagetitle’, ’DESC’);
$childrenCount = count($children);
if (!$children===false)
{
$firstChild = $children[0][’id’];
$firstChildUrl = $modx->makeUrl($children[0][’id’]);
$modx->sendRedirect($firstChildUrl);
}
else
{
}