We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18052
    • 8 Posts
    Hi,

    my first post. I didnt find the info i needed via google search so i decided to "raise my voice" and ask smiley
    But first, let me thank all of you for creating, maintaining, using and abusing that brilliant piece of CMS framework (modx)!!

    My Problem:

    I have several Nodes under the Site Root Folder in modx 9.6.0, that have children themselves.
    Now, i dont want to define content for every document node in the first level.
    Instead, the first child of the node should be displayed.

    As far as i understand, i have to convert the level1 document nodes into folders.
    I did check the "folder" checkbox on the second tab of these certain document nodes (when editing) and save the changes.
    The checkbox stays on, but the document still is a document, not a folder.

    How to convert these documents into folders?

    Best regards,
    makro
      • 5340
      • 1,624 Posts
      The only solution I know is to redirect the folder to one of the childs.

      create a snippet with

      <?php
      $modx->sendRedirect($modx->config[’site_url’] . ’child URL’);
      ?>

      and put the snippet in your folder

      If you find a better solution let me know



        • 4310
        • 2,310 Posts
        There is a snippet to do this called "FirstChildRedirect" in the repository.
        It actually ships with MODx if you install with example data.
          • 4041
          • 788 Posts
          I think whats being asked and misunderstood is that the documents in the tree don’t change to a folder icon or in any visible way show being a container (folder)although they are designated as folder in the document editing space.

          Thinking document or folder in the standard sense is not applicable in the MODx system, any document can be a folder. When a document is marked as a container (folder) it merely means there are children which have it listed as the parent. The folder document can be published, have content which can be presented, or be blank and unpublished.
            xforum
            http://frsbuilders.net (under construction) forum for evolution
            • 18052
            • 8 Posts
            Hi,

            thanks for all your answers so far, but i have two more questions:

            a) How can it be already a folder, if you can define content for it?
            (the editor is shown too)

            b) Does the sendRedirect function really send a redirect (HTTP forward) or does it just display the (forwarded) page?
            (If the answer is HTTP forward, i cant use it)

            many thanks,
            makro
              • 5340
              • 1,624 Posts
              Quote from: makrospex at May 28, 2008, 11:34 AM


              a) How can it be already a folder, if you can define content for it?
              (the editor is shown too)

              Actually is a container. Not a folder. Do not think of it like a OS folder/directory

                • 7231
                • 4,205 Posts
                as for a): the container document is not actually a folder, it is a parent document so it can also have content itself and it behaves as any other document.

                As for b): the firstChildREdirect snippet uses header redirect. But you can use the sendForward api function in a snippet (or modify the original firstChildRedirect to use this function) it actually parses the forwarded page rather than redirecting.
                http://wiki.modxcms.com/index.php/API:sendForward
                  [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                  Something is happening here, but you don&#39;t know what it is.
                  Do you, Mr. Jones? - [bob dylan]
                  • 13577
                  • 302 Posts
                  When I teach content editors of mine how to use MODx, I explain that MODx documents are like real world folders. You can put documents and other folders "in" them, but they can also have content of their own as well, as if you’d taken a pen and written on the folder itself. As mentioned, this is NOT like an OS folder.

                  The only difference between a document and a folder is that a folder has "children." In reality, they’re all just database records.
                    Standard Disclaimer
                    I could be totally wrong.
                    • 18052
                    • 8 Posts
                    Hi,

                    thanks for the quick and detailed replies smiley
                    I will use the sendForward() function from within a snippet.

                    thanks,
                    makro
                      • 18052
                      • 8 Posts
                      Hi,

                      so my "firstChildForward" Snippet does actually not work sad

                      Snippet Code:

                      <?php
                      $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']);
                          $firstChild=1;
                      }
                      return $modx->sendForward($firstChild);
                      ?>
                      


                      Content of a page to be redirected:

                      [[firstChildForward&docid=`2`]]
                      


                      2 is the ID of the Parent which should be forwarded to its first Child (8 in my case).
                      I also stupidly tried a docid parameter value of 8 too.

                      When i navigate to index.php?id=2 i am still presented the (empty) content of the Parent, instead of the defined content of the first Child.
                      Deleted the cache too, still no success sad

                      please help,
                      makro