Guest User

Untitled

a guest
May 27th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <?php
  2. /*
  3. * @name FirstChildRedirect
  4. * @author Jason Coward <jason@opengeek.com>
  5. * @modified-by Ryan Thrash <ryan@vertexworks.com>
  6. * @license Public Domain
  7. * @version 1.0
  8. *
  9. * This snippet redirects to the first child document of a folder in which this
  10. * snippet is included within the content (e.g. [!FirstChildRedirect!]). This
  11. * allows MODx folders to emulate the behavior of real folders since MODx
  12. * usually treats folders as actual documents with their own content.
  13. *
  14. * Modified to make Doc ID a required parameter... now defaults to the current
  15. * Page/Folder you call the snippet from.
  16. *
  17. * &docid=`12`
  18. * Use the docid parameter to have this snippet redirect to the
  19. * first child document of the specified document.
  20. */
  21.  
  22. $docid = (isset($docid))? $docid: $modx->documentIdentifier;
  23.  
  24. $children= $modx->getActiveChildren($docid, 'menuindex', 'ASC');
  25. if (!$children === false) {
  26. $firstChild= $children[0];
  27. $firstChildUrl= $modx->makeUrl($firstChild['id']);
  28. } else {
  29. $firstChildUrl= $modx->makeUrl($modx->config['site_start']);
  30. }
  31. return $modx->sendRedirect($firstChildUrl);
  32. ?>
Add Comment
Please, Sign In to add comment