We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • This is an auto-generated support/comment thread for FirstChildRedirect.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    This snippet was created to have MODx folders emulate the behavior of traditional folders in a web site by redirecting to the first child page it contains.
      • 20765
      • 90 Posts
      myfriendscallmebill Reply #2, 17 years, 9 months ago
      First: Thank you very much for writing this snippet. It’s just what I needed.

      Second: In the usage instructions on the Repository page, in the example for specifying a docid parameter, the example omits the question mark:

      [[FirstChildRedirect &docid=`12`]] <-- as written
      [[FirstChildRedirect? &docid=`12`]] <-- corrected

      It’s a little thing but it had me, as a beginner, tearing my hair out for a short while.
      • Thanks for reporting the typo. I have corrected the instructions in the repository.
          • 5058
          • 5 Posts
          There’s a bug in this snippet. it’s got:

          if (isset ($docid)) {
          $docid= $modx->documentIdentifier;
          }

          when surely what we want is !isset(), ie.

          if (!isset ($docid)) {
          $docid= $modx->documentIdentifier;
          }

          so that if a $docid is not passed, it assumes the current document is the folder.

          • I think you got the original release. The 1.1 version contains:
            $docid = (isset($docid))? $docid: $modx->documentIdentifier;
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 21136
              • 103 Posts
              Hello smiley

              I really appreciate this code. I was going crazy before using this. Been using it for a few months.

              I am using FURL’s - So instead of selecting the firstchild "id", how do I get it to select an alias - let me give example...

              I have many folders and I want the "index.html" page in each folder to be the default. But the "index.html" page isn’t always the firstchild "id" for that folder.

              So how do I get it to look for the "index.html" page in each folder?

              Regards,

              Ken
              • Quote from: nekstrebor at Nov 07, 2006, 02:39 AM

                I have many folders and I want the "index.html" page in each folder to be the default. But the "index.html" page isn’t always the firstchild "id" for that folder.

                So how do I get it to look for the "index.html" page in each folder?

                Hi Ken, thanks for the appreciation...

                The snippet looks for the first child by menuindex order. So you could simply set the menuindex on your index.html files to be the lowest in each folder, or drag and drop sort them using the DocManager module.

                Alternatively, you could modify the snippet and have it loop through the children to find the one with an alias equal to ’index’...but you would need to make sure every folder had an index file as a child or you handle that case in your code.
                  • 14540
                  • 9 Posts
                  This snippet did exactly what I wanted until I really needed the last child instead of the first. After hacking this I decided to modify the original to take an extra parameter:
                  (which is actually a real easy modification)

                  Add:

                  $last = isset($last) ? $last: 0;
                  

                  after: $docid = (isset($docid))? $docid: $modx->documentIdentifier;

                  and replace
                  $firstChild=$children[0];
                  with:

                      $firstChild= isset($last) ? end($children) : $children[0];
                  


                  Now I can FirstChildRedirect?last=`1` and get the last child i.e. the newest news item and still use the original firstchild.


                  Greetings John
                    • 19164
                    • 1,215 Posts
                    I have documents in folder that sorted by TV (datestamp). Is it possible to add more options to snippet call? For example

                    [!FirstChildRedirect?&sortby=`parm` &sortdir=`DESC`!]

                    where "sortby" is document field or TV.

                    And redirect user to first document in list of documents, sorted by this way.

                    Thanks.
                      DirectResize 0.9 beta. PHPThumb, sets of configurations, configuration, binded to specific path. No backward compatibility. | DirectResize 0.9. PHPThumb, наборы параметров, параметры, привязанные к определенным путям. Без обратной совместимости.

                      Unfortunately, DirectResize project is closed. If you want to continue development, PM me for access to project page on Google Code. К сожалению, проект DirectResize закрыт. Если вы желаете продолжить разработки, обращайтесь через ПМ для получения доступа к репозиторию на Google Code.

                      [PLUGIN] DirectResize - as Maxigallery but for single images :: Download :: [url=http://modxcms.com/forums/index.php/topic,21490]
                      • 10357
                      • 573 Posts
                      Using the snippet i get a Redirection limit for this url is exceeded error message in firefox. any fix for that?