We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25663 MODX Staff
    • 12,272 Posts
    Mark, I didn’t think it was necessary to include all the templates in the sample for the sake of demonstration. I’ll be happy to copy paste that if you’d like... my example was simply (incomplete) protocode. tongue

    Using a parameters/include file (or chunk) as I proposed I think resolves your penchant for reducing the number of template files pretty well. Although I still think you’re grossly undervaluing the categories lists recently added to the core.

      Ryan Thrash, MODX Co-Founder
      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • 22815
      • 1,097 Posts
      Right. For the benefit of OpenGeek et al. There are 2 benefits to the "single template", and it is important that we don’t mix them up.

      1: It is quicker to edit one file / on one screen than opening and closing umpteen chunks.
      Leaving Ditto to one side, Wayfinder would be much easier and quicker to tweak if there was just one file to change rather than half a dozen. Creating/opening and then editing and saving all the various chunks is not fun. Having them all open at the same time would have the same benefit, and so yes I will have a look sometime soon at knocking that out.

      2: It is easier to edit the complete desired output as a whole rather than in parts.
      Well, it’s easier to design, certainly. But I think we’ve pretty much agreed that a series of code variables is easier and more efficient to process than a single block of code. I doubt any of us would seriously suggest having a routine that split up a PhotoShop file into a header, repeating background and footer on every page. No, you export the files once and reuse them.

      So I think the focus instead should be on a method of converting a single template to a series of variables on a one-time basis. (I say one-time, but every time the template changed, the routine could be re-run. This is still better than doing it on every page request). This could be a how-to guide for humans or some sort of tool. Either way, it’s not built into Ditto.

      The edit category at once solution
      I guess I did volunteer for that.. I’m going to see what the present code looks like before I commit to a timeframe on it. I guess individual Save buttons and a Save all button would be required.

      The single file solution
      There are presently two places to set variables: the snippet call, and in the snippet itself. A third method - loading from another file/chunk specified in the snippet call would indeed be great. As I have said before, I believe this should be part of MODx rather than part of Ditto.

      All we need to be aware of is that there is a difference between passing through the content of a chunk and passing through the name of a chunk. So where $dittoItem is the existing chunk name, future Ditto needs to have both $dittoItem and $dittoItemContent; if $dittoItemContent isn’t set it loads from the chunk specified to $dittoItem. Arguably, with the recursive parser, all we need is $dittoItemContent as the content could be passed through at the call, but it’s probably worth keeping for code compatability.

      If there were a tool that converted an XML template to a file containing separate chunk values, then this would be even better, but it’s not essential now.
        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

        If there were a tool that converted an XML template to a file containing separate chunk values, then this would be even better.

        This is possible but would require a plugin to say on changing a chunk to flush out the cache...
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: PaulGregory at Aug 20, 2006, 12:18 PM

          Right. For the benefit of OpenGeek et al. There are 2 benefits to the "single template", and it is important that we don’t mix them up.

          1: It is quicker to edit one file / on one screen than opening and closing umpteen chunks.
          Leaving Ditto to one side, Wayfinder would be much easier and quicker to tweak if there was just one file to change rather than half a dozen. Creating/opening and then editing and saving all the various chunks is not fun. Having them all open at the same time would have the same benefit, and so yes I will have a look sometime soon at knocking that out.

          2: It is easier to edit the complete desired output as a whole rather than in parts.
          Well, it’s easier to design, certainly. But I think we’ve pretty much agreed that a series of code variables is easier and more efficient to process than a single block of code. I doubt any of us would seriously suggest having a routine that split up a PhotoShop file into a header, repeating background and footer on every page. No, you export the files once and reuse them.

          ...

          The single file solution
          There are presently two places to set variables: the snippet call, and in the snippet itself. A third method - loading from another file/chunk specified in the snippet call would indeed be great. As I have said before, I believe this should be part of MODx rather than part of Ditto.

          Now we’re talking benefits; and thanks for the input Paul. I agree that these are benefits indeed, and the approaches being discussed would work for the interim, I suppose.

          But let me say that a better solution to this problem, in my perspective, is to have an integrated editor of related templates and subtemplates, aggregated into one view, which is constructed from the pieces and resaved as the individual, reusable elements they are best represented by in the database. You could even have a tree to navigate to various sections, or out to say, other types of editable elements represented by tags (snippets, TV’s) that are used in the template.

          This was my approach/goal for 1.0 in this regard. Without an approach like this, proper versioning and multi-cultural management of such content would be impossible. This is also why I argue we should stay away from additional methods of introducing themes/templates, and start moving towards staying consistent with the storage and retrieval of all content managed by MODx, letting the user interfaces do the work of managing that data for ease of use issues. This ultimately allows complete optimization of the rendering and caching processes for the front-end, and offloads it to the content management interfaces, where it belongs.

          Quote from: Mark at Aug 20, 2006, 01:56 PM


          If there were a tool that converted an XML template to a file containing separate chunk values, then this would be even better.

          This is possible but would require a plugin to say on changing a chunk to flush out the cache...
          Again, all part of the move to becoming consistent with our storage and retrieval methods, so caching and other important aspects can be better managed by the core. This is why a single, consistent API into the persistent data managed by MODx is so important; without it, we are forced into the solutions being suggested here.

          So don’t take what I am saying as resistant, just trying to find the best path to solve this now without complicating future migratation efforts of our core snippets and every snippet someone creates based on the core snippets.
            • 22815
            • 1,097 Posts
            I guess it all depends how long the interim is.

            Quote from: OpenGeek at Aug 20, 2006, 02:41 PM

            But let me say that a better solution to this problem, in my perspective, is to have an integrated editor of related templates and subtemplates, aggregated into one view, which is constructed from the pieces and resaved as the individual, reusable elements they are best represented by in the database. You could even have a tree to navigate to various sections, or out to say, other types of editable elements represented by tags (snippets, TV’s) that are used in the template.
            Sounds fab, but the big thing that we don’t have is "related templates and subtemplates". We have templates/subtemplates that are *specified* by snippet calls. Are you suggesting that the 1.0 backend could have an Edit Page screen with a tree that branched out not just the tags but the chunks referenced within those tags? And that there could be a different chunk content for each culture, where appropriate? And all on one screen?
            Or that this is what we should write now for 0.9.5?

            Quote from: OpenGeek at Aug 20, 2006, 02:41 PM

            This is also why I argue we should stay away from additional methods of introducing themes/templates, and start moving towards staying consistent with the storage and retrieval of all content managed by MODx, letting the user interfaces do the work of managing that data for ease of use issues.
            In which case it sounds like the best interim solution is the "edit multiple things on one screen", using the new categories.

            Quote from: OpenGeek at Aug 20, 2006, 02:41 PM

            [re "would require a plugin to say on changing a chunk to flush out the cache..."]
            Again, all part of the move to becoming consistent with our storage and retrieval methods, so caching and other important aspects can be better managed by the core. This is why a single, consistent API into the persistent data managed by MODx is so important; without it, we are forced into the solutions being suggested here.
            Right. So there’s a SaveChunkData routine that also flushes out the cache. A single consistent API doesn’t change the need for these solutions, it just changes how much coding we have to do to achieve them.

            Quote from: OpenGeek at Aug 20, 2006, 02:41 PM

            So don’t take what I am saying as resistant, just trying to find the best path to solve this now without complicating future migratation efforts of our core snippets and every snippet someone creates based on the core snippets.
            My reading of your posts is that the best path is to do nothing and await 1.0 which will make everything easier, although it is unclear where we’re up to with this and who’s doing what - there’s a lot of talk about the 1.0 API enabling things in the 1.0 Manager but it would seem that there is a lot to be done between completion of 1.0 API and 1.0 Manager.
              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!
              • 22303 MODX Staff
              • 10,725 Posts
              I’m not saying do nothing now for sure. I’m simply trying to shape the thinking of what solutions do get crafted now. And I agree with your assessment of the best interim 100%.
                • 18397
                • 3,250 Posts
                I pulled all of the XML templating out of Ditto and replaced it with heredoc variables for the format specific template code. As for the archive, you still can only template the outside and inside... none of the ul or li items though...
                  • 22815
                  • 1,097 Posts
                  Sounds good.

                  Can’t remember if I’ve said this in the thread, but it would be really useful if you could run one Ditto snippet specifying a variable to throw the results into, and then run further Ditto snippets referencing the same data. That approach would potentially mean that you could run Ditto, and then run DittoArchive - which might be an separate snippet with different template bits - or another Ditto with different template bits specified to make it function like an archive. There seem to be a few people who want to show 2 items, then an advert, then some more items, so this approach would save a lot of db hits.
                    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!
                    • 22303 MODX Staff
                    • 10,725 Posts
                    Quote from: PaulGregory at Aug 28, 2006, 07:05 AM

                    Can’t remember if I’ve said this in the thread, but it would be really useful if you could run one Ditto snippet specifying a variable to throw the results into, and then run further Ditto snippets referencing the same data. That approach would potentially mean that you could run Ditto, and then run DittoArchive - which might be an separate snippet with different template bits - or another Ditto with different template bits specified to make it function like an archive. There seem to be a few people who want to show 2 items, then an advert, then some more items, so this approach would save a lot of db hits.

                    This is the approach that should be followed moving forward with all core add-ons, IMO. Small, loosely coupled pieces that share data, helping to reduce overall rendering time and memory usage. Monolithic components are troublesome any many ways, not the least of which can be poor performance, less flexibility, and configuration nightmares.
                      • 25663 MODX Staff
                      • 12,272 Posts
                      Small, loosely coupled pieces that share data, helping to reduce overall rendering time and memory usage. Monolithic components are troublesome any many ways, not the least of which can be poor performance, less flexibility, and configuration nightmares

                      I couldn’t agree more... and exactly the reason why UltimateParent functionality was removed from Wayfinder.
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me