Hi,
It is actually possible to use FirstChildRedirect with YAMS after small modification in the snippet.
The solution is tested with YAMS in root mode.
Change the snippet like this:
1. Add additional parameter which switches the mode of the snippet (yams or legacy).
2. In case of yams mode remove the first slash from $modx->makeUrl
3. Call the redirect (in the example it is done by php header() function, but I would expect that $modx->sendRedirect() will work as well
<?php
/*
* @name FirstChildRedirect
* @author Jason Coward <[email protected]>
* @modified-by Ryan Thrash <[email protected]>
* @license Public Domain
* @version 1.0
*
* This snippet redirects to the first child document of a folder in which this
* snippet is included within the content (e.g. [!FirstChildRedirect!]). This
* allows MODx folders to emulate the behavior of real folders since MODx
* usually treats folders as actual documents with their own content.
*
* Modified to make Doc ID a required parameter... now defaults to the current
* Page/Folder you call the snippet from.
*
* &docid=`12`
* Use the docid parameter to have this snippet redirect to the
* first child document of the specified document.
*/
$docid = (isset($docid))? $docid: $modx->documentIdentifier;
$mode = (isset($mode))? $mode :"";
$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']);
}
if ($mode=="yams"){
header( 'Location: ' . substr($firstChildUrl,1) , TRUE, 303);
return;
}
else {
return $modx->sendRedirect($firstChildUrl);
}
?>
To state again - this is tested only with root mode of yams and modx in the root of the web.