Skip to content

Instantly share code, notes, and snippets.

@ideesimple
Created December 2, 2010 08:51
Show Gist options
  • Save ideesimple/725002 to your computer and use it in GitHub Desktop.
Save ideesimple/725002 to your computer and use it in GitHub Desktop.
snippet FirstChildRedirect
$docid = (isset($docid))? $docid: $modx->documentIdentifier;
$children= $modx->getActiveChildren($docid, '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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment