We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 35986
    • 46 Posts
    Developing a ModX site at showmedia.dev.agriya.com. I’m fairly new, so tech jargon may fly over my head. In my "Our Networks" nav (top, far left), I have several networks which contain a number of resources within the "related projects" area of each page. Each of these "projects" are resources within another resource with the name of the particular network. If you navigate to "all projects" (far right of "related projects" on each page) you should be able to view all of the projects from all of the networks, but i need to know how to flow all of the networks’ resources into this "all projects" resource. In other words, the user should be able to add a project to each Network’s "Related Projects" list and have it automatically picked up by the "all Projects" resource as well. My developers just put an arbitrary number of random resources in there and left me holding the ball. Can anyone help? Am I being clear? Thanks so much in advance.
    • Sounds like a bunch of Ditto snippet calls. Its &parents parameter is used to specify which container resource to start with, listing all of that resource’s children. To list from more than one container (parent) resource, use a comma-delimited list:
      [[Ditto? &parents=`2,4,65,234`]]

      And of course like all of the major MODx snippets, it uses mini-tpls for structuring the output. The default tpl (in the language files in assets/snippets/ditto/lang/) is
          <div class="ditto_item" id="ditto_item_[+id+]">
              <h3 class="ditto_pageTitle"><a href="[~[+id+]~]">[+pagetitle+]</a></h3>
              <div class="ditto_documentInfo">by <strong>[+author+]</strong> on [+date+]</div>
              <div class="ditto_introText">[+introtext+]</div>
          </div>
      

      I find it easiest to just copy this into a chunk, make sure it’s working when specified in the parameters, then edit it as required. Ditto has phx built-in, so the template can have all kinds of conditional code.

      Ditto documentation is a bit scattered, and the "official" documentation was never very friendly. I use the Pogwatch site. I also have a cheatsheet; I’ll attach it here for you.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 35986
        • 46 Posts
        aha, of course. that makes sense. have the resources claim more than one parent, one being the "all projects" list. is this what you meant? also what is this about tpl? what’s its purpose? why do i need... thanks btw.
          • 35986
          • 46 Posts
          i’m afraid i still don’t understand how to publish a resource to multiple parents... i’m very new to this. where do i concatenate the id’s? how can i do this so the client can freely make as many of these resources as he/she likes and have them automatically publish to two parents (i.e. "Related Projects" and "All Projects")? thanks.
            • 16278
            • 928 Posts
            A resource can only have one parent. You need to look at the Ditto calls as a "pull" mechanism, with different calls pulling data from resources which can have different and overlapping parents, and formatting the data using chunks and placeholders for output on the page containing the Ditto call.

            Let’s say you have

            Network 1 (id=66)
            project n1-1
            project n1-2
            etc

            Network 2 (id=69)
            project n2-1
            project n2-2
            etc

            Your Network 1 and Network 2 listing pages (resources 66 and 69) would have a Ditto call including
            [!Ditto? &tpl=`format.chunk.for.networkspage` !]

            If they are the parents of the project pages, there’s no need to specify &parents, as the current document is the default &parents parameter.

            The &tpl parameter names a chunk for formatting the output from each retrieved document. This will include static HTML code and placeholders such as [+longtitle+] for the data that varies from one document to the next.

            Your "All Projects" page will be a resource with a Ditto call specifying the network head pages as multiple parents, and a different template chunk, if required, for outputting elements of the retrieved documents:
            [!Ditto? &parents=`66,69` &tpl=`format.chunk.for.overviewpage` !]


            With no further parameters, the combined list will be displayed in descending order of the project pages’ creation dates. You can use &orderBy parameter (with multiple settings for sorts within sort) to change that.
            smiley KP
              • 35986
              • 46 Posts
              i tried to list several ids for the &parents parameter of the "all projects" page but it returned an parse error saying the list was not "numeric"...
                • 16278
                • 928 Posts
                Please copy/paste your Ditto call for us to see.
                :o KP
                  • 35986
                  • 46 Posts
                  All Projects:
                  {{show-media-menu}}

                  [!Ditto? &parents=`275,385` &dateSource=’all-project-list’ &removeChunk=`Comments` &tpl=`all-project-view` &paginate=`1` &paginateAlwaysShowLinks=`1` &display=`24` &extenders=`summary,dateFilter` &tagData=`documentTags`!]

                  [+previous+] [+pages+] [+next+]
                    • 16278
                    • 928 Posts
                    The &parents look fine. What is "all-project-list"? Whatever it is, you have ordinary single quotes around it, where you need `backticks`. Does the call work with this parameter removed?
                    laugh KP