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.
The problem with doing that is that people have to understand escaping strings as you can’t have quotes inside quotes, etc...
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?
-
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
Heredoc is great except I would like to keep the MODx theme of a user not having to see php to template something.
-
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.
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.