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

    I have a container with a couple of levels in it and wish to display documents from specified levels. I’ve tried the &depth parameter but it seems to display all documents down to the specified depth as opposed to only documents at that depth.

    Any help our suggestions would be welcome.

    Cheers

    Ben
      • 1122
      • 209 Posts
      Yes, &depth=`X` means grab all to X’s depth. However, your task still may be solved in several ways. First, the simpliest one.

      Designers usually mark different levels in a document tree with specific templates. Provided that your project does so (documents within each level are marked with its own template), then you can simply filter out docs of unwanted levels:
      [[Ditto? ... &depth=`X` &filter=`template,Y,1` ... ]]
      

      The above grabs all docs to X’s depth, but throws out all those whose template is not equal to Y. Template is a numerical value -- you need to check in manager (or even in DB) the correct template id used for docs of X’s level.

      If this scenario cannot be applied for some reasons, then the more advanced should be arranged...
        • 5532
        • 251 Posts
        Awesome tip!

        I’d seen the filter stuff on the Ditto site but didn’t really understand how to filter by anything other than the example shown (which was id).

        It didn’t work until I changed the filter to exclude if equal (2). For my ref, here’s the call I used.
        [!Ditto? &id=`blog` &parents=`[[UltimateParent]]` &depth=`3` &filter=`template,21,2|template,19,2|template,35,2` &etc...


        I used ultimate parent so I won’t have to change the ID if the client duplicates the entire container for another purpose like a recipe section or whatever.

        Thanks again...

        Cheers

        Ben
          • 6705
          • 79 Posts
          Quote from: alik at Feb 02, 2010, 03:37 AM

          Designers usually mark different levels in a document tree with specific templates. Provided that your project does so (documents within each level are marked with its own template), then you can simply filter out docs of unwanted levels:
          [[Ditto? ... &depth=`X` &filter=`template,Y,1` ... ]]
          

          The above grabs all docs to X’s depth, but throws out all those whose template is not equal to Y. Template is a numerical value -- you need to check in manager (or even in DB) the correct template id used for docs of X’s level.

          This is useful advice, thanks.

          Do you (or anybody else) know whether it is possible to use the filter parameter to exclude ’container pages’ (but not the documents within each container)?

          I’d like to use Ditto to set up a simple blogging system, but I’m a little concerned that, several years down the line, that the folder with the blog pages will start to get a bit unwieldy (if not for MODx itself, certainly for the human editors), by containing a large number of documents. I figured that a workaround could be to create a new folder/container for each year, within the main blog folder. The content of all of the folders could be aggregated by Ditto using the depth parameter, and also has (what I see as, for news) the advantage of including the year in the document URL.

          However, first attempts show that the container/folder ("pseudo-article") for the year itself also gets aggregated into the Ditto blog output, which is undesirable. Is there a way to filter out each of the containers from the output, and only include their child pages? (I intend to only have one level of sub-folders (ie, a folder for each year), nothing more complicated than that.)

          Thanks for any advice.
            Please don't PM me unless it's absolutely essential: if a technical question is worth asking, it's worth asking in public, so that others can share their experience, and so that all can learn from the answers.
            • 1122
            • 209 Posts
            Yes, MODx document has special field for marking whether it is container or not. Your Ditto’s filter for excluding containers:
            [[Ditto? ... &filter=`isfolder,1,2` ...]]
            
              • 36416
              • 589 Posts
              Quote from: alik at Mar 03, 2010, 10:39 AM

              Yes, MODx document has special field for marking whether it is container or not.

              Even better, Ditto already knows which documents are folders:
              http://ditto.modxcms.com/files/snippet-ditto-php.html#hideFolders