We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22815
    • 1,097 Posts
    Sounds like more work for everyone concerned, including Ditto. That’s a lot of parsing to be done.
    I still maintain that it would be easier to have one file/chunk/whatever containing:

    $chunk1 = "stuff";
    $chunk2 = "morestuff";

    Ideally, this would be built into MODx; you could then add &loadParChunk=`dittoparschunk` or &loadParChunk=`googlemapsettings` to any snippet call and MODx would know to load in the values from a chunk. And &loadParChunk=`dittopars` could work from a file.

    From Ditto’s perspective, you’d just need to be able to distinguish between a chunk reference and actual content - that may require parallel parameters.

    However, there may be some merit in being (optionally) able to create this chunk/file from an XML-based template.
      No, I don't know what OpenGeek's saying half the time either.
      MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
      Forum: Where to post threads about add-ons | Forum Rules
      Like MODx? donate (and/or share your resources)
      Like me? See my Amazon wishlist
      MODx "Most Promising CMS" - so appropriate!
      • 18397
      • 3,250 Posts
      The problem with doing that is that people have to understand escaping strings as you can’t have quotes inside quotes, etc...
        • 22815
        • 1,097 Posts
        Good point. Heredoc syntax then?
        $chunk1 = <<<EOT
        bar
        EOT;


        From another perspective - and apologies for going off the topic of XML Templating - now that we have chunk grouping etc, how about an "edit all the chunks in this group at once" screen?
          No, I don&#39;t know what OpenGeek&#39;s saying half the time either.
          MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
          Forum: Where to post threads about add-ons | Forum Rules
          Like MODx? donate (and/or share your resources)
          Like me? See my Amazon wishlist
          MODx "Most Promising CMS" - so appropriate!
          • 25663 MODX Staff
          • 12,272 Posts
          Cool, no GREAT, idea Paul... you volunteering to create that manager page and logic?
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 18397
            • 3,250 Posts
            Heredoc is great except I would like to keep the MODx theme of a user not having to see php to template something.
              • 25663 MODX Staff
              • 12,272 Posts
              Mark, if people can get passing in parameters and reading comments for documentation, they can handle heredocs syntax. In fact, if they can handle a CMS period, they can handle it (can you tell I think it’s the best proposal so far?).

              I would use a slightly different sytax though:

              // This is the template for doing blah
              $chunk1 = <<<TPL
              blah blah blah
              TPL;
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 22303 MODX Staff
                • 10,725 Posts
                Ryan, that would not be heredoc syntax then, and would have to be parsed manually.

                And I guess I still don’t understand all this discussion of having additional files of templates outside of MODx or having sections of a chunk represent individual templates. With categorization, it should be easy to group a set of chunks along with a snippet, so it’s easy to manage them. I use this technique in custom snippets all the time now, and simply do not understand this need for combining templates into one. I for one would much rather have the modularity benefits of keeping these things separate (and in the process making them more reusable). As individual pieces of content, there are no separators or special syntax to learn, no need for extra parsing in your snippets, and generally it just helps keep the functionality as generic as possible.

                I think we need to first identify why we need these multi-part templates and see how we can best address this consistently. I believe the recursive parsing features that will soon be available should address most, if not all of these issues and I just fear we are adding unnecessary complexity to core components, which serve as the primary examples of how to develop add-on’s for MODx.
                  • 18397
                  • 3,250 Posts
                  Places where multi-part templates are beneficial:

                  1. For things with subtemplates like the archive
                  2. For things like RSS and JSON which have a header and footer associated with them

                  @Jason: You can use any string after the <<< and heredoc still works so long as it is the same string at the end with the semicolon according to the php documentation.
                    • 25663 MODX Staff
                    • 12,272 Posts
                    You confused man... it can be anything you’d like it to be on the three little capitalized letters.

                    I’ve seen it work just fine as EOD, and XXX... I suspect it would work as IAMASILLYHIPPIE as well. tongue
                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                      • 22303 MODX Staff
                      • 10,725 Posts
                      DOH! embarrassed I didn’t realize that... [silly hippie, learning new tricks]