We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27226
    • 186 Posts
    I think, after having read the last posts, I know a bit better what tillda’s concerns are:
    Indeed: a snippet/chunk/plugin can spit out what it likes: plain data or fully formatted, or css-depending HTML. Then: those items can be nested into one another, a chunk may call a snippet and vice versa.
    So, logic might be cluttered all over heterogenous, nested components of the system, as well as presentational stuff. Especially in complex sites (not necessarily LARGE sites) it can be very tricky to find out how things work and why a page is displaying what it is displaying. I frequently asked myself, why there is no easy way to "share" solutions. (of course, technically I know why) For instance: if I find a great navigation in a MODx site, why can’t I just "import" it? Basically that’s due to the MODx architecture and the phenomenons I mentioned at the beginning of this post. XML could enforce the differentiation of logic and presentation and it could make components like fully configured snippets etc. more portable.
    Interesting stuff, btw... wink
      • 22815
      • 1,097 Posts
      Crikey, if you are concerned about nested components *now*, wait until you see what can be done in 0.9.5...

      It is entirely true that a large MODx site could be a large mess. However, that’s not actually MODx’s fault, and "enforcing" any distinction between logic and presentation just makes it take longer to Get Things Done.

      All MODx webmasters should name snippets/templates etc in logical ways and document things (using the available description field and other notes) so that anyone could pick up the site and continue it, or indeed the MODx admin could leave the site for several months and come back to it after he’s forgotten everything and figure it out again.

      In reality, during development plans will change and so things need to be flexible. Only *after* a site is complete and signed off by the client can any MODx-master tidy things up properly. But that can happen now. I really fail to see how XML or the entirely different and not-XML template system in the link would help declutter a site.

      Quote from: silent at Aug 31, 2006, 01:09 PM
      For instance: if I find a great navigation in a MODx site, why can’t I just "import" it?
      Um, because all View Source reveals is the presentation, rather than the logic?

      Quote from: tillda at Aug 31, 2006, 10:26 AM

      I liked that article becouse it matched one idea that I had abouth month ago. This idea was about converting all HTML in templates, chunks and snippets to XML, so the output would be clear XML.
      Eh? Can you please check the article you linked to and tell me where the idea matches?
        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: silent at Aug 31, 2006, 01:09 PM

        I think, after having read the last posts, I know a bit better what tillda’s concerns are:
        Indeed: a snippet/chunk/plugin can spit out what it likes: plain data or fully formatted, or css-depending HTML. Then: those items can be nested into one another, a chunk may call a snippet and vice versa.
        So, logic might be cluttered all over heterogenous, nested components of the system, as well as presentational stuff. Especially in complex sites (not necessarily LARGE sites) it can be very tricky to find out how things work and why a page is displaying what it is displaying. I frequently asked myself, why there is no easy way to "share" solutions. (of course, technically I know why) For instance: if I find a great navigation in a MODx site, why can’t I just "import" it? Basically that’s due to the MODx architecture and the phenomenons I mentioned at the beginning of this post. XML could enforce the differentiation of logic and presentation and it could make components like fully configured snippets etc. more portable.
        Interesting stuff, btw... wink

        Now, if you leave XML out of what you are saying, I’ll agree with you. But IMO, XML is not the answer for MODx. There are plenty of frameworks that follow the MVC implementation that was first popularized with Struts, and they are available today. Symfony being my personal favorite PHP implementation of this. I will not allow MODx to go this direction, and if anyone says the word `portlet` or `portal`, I’ll scream. tongue

        Instead, I believe the answers are simply object-orientation (encapsulating business logic, as well as making it extensible by simply extending a class), object-relational mapping with a standardized format for exchanging MODx, or any other data (with tools to allow data mapping or transformation to be as easy as mapping fields in a UI), and allowing direct relationships between components to be defined and managed easily. Now XML (and/or YAML and/or JSON and/or etc.) is still useful, but IMO, it better serves as a tool that we can utilize for cross-platform data sharing, remote-procedure calls, new document subclasses to represent web services or Ajax service that reads and/or writes XML, or a new subclass of snippet that needs an XML template (and maybe that’s stored as an instance of a chunk with an XML content type). But as for adopting XML as a core configuration component or templating language for these elements of content (chunks, snippets, TVs, etc.), I’ll pass. But would make a great extension IMO. Some people like the Struts approach, and the future will allow us all to get along without enforcing such limitations on everyone.

        Object-oriented patterns applied to MODx will help reduce the amount of code, increase the effectiveness of opcode caching techniques, increase code reusability, reduce the need for hacking any file at all, and at the same time can still be used to enforce the isolation of Models and Views, which is what we are essentially debating here.

        Abstracting the data layer and applying the ActiveRecord, and some other emerging OR/M-related patterns, will allow both consistency in API design, in managing the lifecycle of the core data model, as well as in the automation of custom extensions to it.

        Direct relationships between components (i.e. chunks related to a snippet which uses them as templates, or TV definitions related to a snippet which requires them, or a chunk related to a plugin, etc.) will help silently enforce the separation of presentation and logic, while at the same time increasing the flexibility of it. Combined with the OR/M layer, we can then import and export objects and exchange them with other MODxers via whatever agnostic data format we choose, be it executable PHP, XML, YAML, JSON, or whatever else becomes popular for a while, and this same import/export can be utilized to easily define and distribute vertical solutions of just about any kind.
          • 22815
          • 1,097 Posts
          But but but...

          Logic *needs* to be nested.

          Even object-oriented stuff can nest!

          I think this discussion would work better with an example:

          We have a snippet called MyDateMyWay, which takes a date and replaces it with "Today 7:30pm" / "Tuesday 7:29pm" / "25th December 2005", etc, with a class around the date and a class around the time (if there is one - it is skipped for documents older than a week)

          We have another snippet which lists documents with publication date according to a template. The publication date is passed to MyDateMyWay and inserted into the Ditto template.

          A template surrounds the whole thing, which also runs MyDateMyWay with the current date.

          Now: if you don’t want MyDateMyWay to return CSS, then it needs to return two strings - the date and optionally the time.
          And then what?
          I’ve seen templates that do this:
          <span class="time">[+time+]</span>

          which is dire because you end up with empty classes.

          I’ve also seen templates that do this:
          IF showtime {
          <div class="time">[+time+]</div>
          }
          

          which require ANOTHER variable to be set.

          And yes, I’ve seen systems with templating systems that have added the CSS into the variable. (Or even just echoed it out..)
          Why? Because it works.

          See, very often there is presentation logic that is most efficiently executed at the same time as other logic. If you make a rigid separation between "applying presentation" and "producing output from data according to logic", you risk stopping "producing output with presentation applied". Which actually means that instead of there being one place to go to to find the date/time snippet, you have to look at some PHP code and a mini-template.

          Where is the benefit?

          And if you switch to objects... what? I want to pass a datestamp to MyDateMyWay and use the output in another.. object. And I want a class around Date and a class around Time. My understanding of objects is that I would have to first set the input time on one line and then I could get each output. This seems quite far away from the existing snippet format - which is largely function based. That just doesn’t sound like MODx any more.

          And what’s with the object-sharing? What the heck is wrong with sharing snippets etc? I just don’t get the need to change. I like MODx and what you are talking about sounds so far removed from what I like about MODx that it freaks me out.
            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!
            • 27226
            • 186 Posts
            Of course, PaulGregory, this is a quite theoretical discussion here - at least partly. And I frankly admit that I do not have the competence to grasp everything that Jason has explained above.
            Anyway you’re right: it has no direct relation to MODx, not even to Tattoo, at least as far as I can follow the arguments passed here.
            To cut it down to a very practical point: It would be very helpful, if one could log all the actions the parser takes to render a page, the sequence in which all components involved are resolved etc. Would be great for debugging, for understanding and benefit from the solutions of others.
            In a practical sense, the differentiation between logic and presentation is up to the discipline of the site’s developer, to the degree he follows "best practices" like "whenever you see a ’<[any html tag]>’ in the output of a component which does logic, you’re on the way to mess things up".

            The other practical issue I see here is the handling of snippets/plugins/modules which tend to become "subsystems" like Ditto. More than once I found it more difficult to handle these components than MODx itself. And I argue that there is a tendency behind that. If, for instance, I compare Wayfinder with its predecessor DropMenu, the latter was more self-contained. Wayfinder uses chunks to store its config-params, and those chunks use special WF-tags. It works, ok, but I fear if this tendency continues, only a few gurus will be able to find out why and how it works... wink The degree of expertise required to accomplish something with MODx is increasing. And there are good reasons to reflect the causes for that - and possible consequences.
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: PaulGregory at Aug 31, 2006, 06:13 PM

              See, very often there is presentation logic that is most efficiently executed at the same time as other logic. If you make a rigid separation between "applying presentation" and "producing output from data according to logic", you risk stopping "producing output with presentation applied". Which actually means that instead of there being one place to go to to find the date/time snippet, you have to look at some PHP code and a mini-template.

              Where is the benefit?
              I’m clueless as to what you mean here in regards to the topic at hand, which is the implementation of the templating system itself. Nothing I said included making a rigid separation between those concepts, nor would I ever. I was arguing just the contrary, that MODx provides the framework for you to approach templating in just about anyway you want to. That is the benefit.

              Quote from: PaulGregory at Aug 31, 2006, 06:13 PM

              And if you switch to objects... what? I want to pass a datestamp to MyDateMyWay and use the output in another.. object. And I want a class around Date and a class around Time. My understanding of objects is that I would have to first set the input time on one line and then I could get each output. This seems quite far away from the existing snippet format - which is largely function based. That just doesn’t sound like MODx any more.

              And what’s with the object-sharing? What the heck is wrong with sharing snippets etc? I just don’t get the need to change. I like MODx and what you are talking about sounds so far removed from what I like about MODx that it freaks me out.
              I just think you’re missing the point of what I’m talking about that is changing. In fact, it’s not different on the surface at all, so don’t freak out (not sure why you are). All it does is make maintaining, evolving, and extending the core of MODx itself much easier, more enjoyable, and more prone to collaborative development. And, I hope will help make MODx a more realistic choice for serious PHP developers.

              It’s just the core I’m discussing that is going to be implemented in an object-oriented way, not that snippets are becoming objects or anything like that, though being able to manipulate objects like any other snippet parameter or placeholder is already possible in MODx. But to stay on topic, rather than a endless spaghetti stream of redundant core code that must be hacked in 12 places to change very simple things, you can simply extend core classes to modify their behavior, or extend it in some creative way (i.e. modDynamicSnippet extends modSnippet = a snippet that parses any tags in the PHP source before execution, or modAjaxResource extends modResource could return XML or JSON representations of any core or custom class). By encapsulating this core behavior, the development of snippets is benefited, by a more consistent approach to the API and a centralized place to modify or extend the behavior of things. Something that is painful at best now when working with or extending the core of MODx, and IMO, still painful when developing snippets with the rather ad hoc API that have been stuffed into one huge class.

              Other benefits of objectifying persistent data classes (or your model): it makes working with them in more generic ways (form generation/processing, table generation/processing, etc.) possible, making snippets more applicable to more situations; and it can certainly help in opening new possibilities for caching and other performance improvements. I’ve used the concepts on several live sites with a significant number of custom data objects, and accomplished some very cool things that I think might also make you freak out when you see them, but in a happier kind of way.

              An example, the data layer can generate instant models or API’s of any database, making the data instantly available to you in the same familiar way as any core data in this new MODx core, built on top of PDO. I’ve used it to design a custom calendar system I’m going to release soon, to reverse-engineer the db’s of WordPress, MD-Pro, and even a commercial Flash gallery toolset with a MySQL backend, and then use the generated API’s to write snippets, single-page scripts to migrate data, to develop a single new class to loosely integrate two user systems, or to extend a single method in my user class to change the way it works.

              Once you have this ability to create and manage models, or business logic layers, in the same simple and intuitive way MODx makes designing XHTML/CSS layouts, presentation of the model via snippets, chunks, and such becomes much more focused on presentation as it should, while still allowing access to the model in what I think are revolutionary ways, all made possible by combining these changes (which are all either MVC-derivatives or based on other proven or emerging design patterns) I’m trying to describe with the existing way MODx works.

              I could go on, but the benefits of object-orientation, design-patterns, and these other things I’m describing, are in my mind, indisputable.

              Quote from: silent at Aug 31, 2006, 06:43 PM

              The other practical issue I see here is the handling of snippets/plugins/modules which tend to become "subsystems" like Ditto. More than once I found it more difficult to handle these components than MODx itself. And I argue that there is a tendency behind that. If, for instance, I compare Wayfinder with its predecessor DropMenu, the latter was more self-contained. Wayfinder uses chunks to store its config-params, and those chunks use special WF-tags. It works, ok, but I fear if this tendency continues, only a few gurus will be able to find out why and how it works... wink The degree of expertise required to accomplish something with MODx is increasing. And there are good reasons to reflect the causes for that - and possible consequences.

              I think it’s just the opposite; it’s getting less complex to develop better custom solutions with it. I don’t think any of us contributing here are in the business of providing out-of-the-box solutions on top of the MODx framework that are easy for everyone to use. I contribute to it so I can do what I do, which is make a living from developing and maintaining custom database-driven web sites with it.
                • 27226
                • 186 Posts
                Quote from: OpenGeek at Aug 31, 2006, 07:16 PM

                I don’t think any of us contributing here are in the business of providing out-of-the-box solutions on top of the MODx framework that are easy for everyone to use.
                Nasty check-back: And if one of us were? (not me, just to make that clear) Would also be a honorable type of business. grin And even more than that: It could function as a "proof of concept":
                The longer you can stick to the "out-of-the-box" idea, the more usuable the product will get.

                The dilemma appearing in this thread is to match end-user and developer requirements, and to position MODx somewhere in this field. MODx makes a lot of points in templating (i.e. in the scene of web-designers) and is therefore very attractive for those who know how to deal with HTML and CSS. The developers, charged with implementing - and maintaining! - more complex features will easily find out that they do not only have to deal with the core, but with what I named "subsystems" too, and that they will have to adjust themselves to learn and to use this environment and any snippet-component properly.

                At the end I come back to the question which came to my mind when I first met MODx:
                "CMS AND framework in one ’product’? Is that possible?"
                I have the feeling that this first question is what pops up here again - after months of trying to learn MODx and its philosophy. So, there is still no answer for me ... but a highly interesting challenge!
                  • 8363
                  • 28 Posts
                  While I marvel with great interest (and esteem) at the forward looking intentions of these posts, I can’t halp but question whether or not this debate is far too esoteric for the typical CMS user who is looking for a practical solution (and the best way to implement) without getting locked in to a proprietary solution? You guys sound like you’re capable of developing a state-of-the-art web app. Why are you waisting your time with MODx. grin

                  Sorry, I’m sure there’s some relevance to this debate, however I wish such talented capacities were being applied to the guidance of the MODx community that is becoming your user base.
                    • 25663 MODX Staff
                    • 12,272 Posts
                    We’ve never set out to be a run of the mill CMS. That’s been stated from day one. Our target is not run of the mill end users, just to reiterate a point I’ve made over and over and over again. We’re building a great platform on which you can build custom web apps. It just so happens that MODx is a great platform for managing content, so it’s easy to get stuck in the rut of thinking of it in a pure CMS mentality.

                    Now that’s not to say we won’t one day be your mother’s and grandmother’s and non-technical users’ CMS solution, but right now our goal needs to squarely be on making a killer framework. We’ll gladly sacrifice massive uptake and "market share" for a platform that stands a chance of making it in the long term. We want to see MODx around in 10 years, and I honestly don’t think where it stands today will take us there. It’s time to make some serious changes for the better.

                    With that out of the way and said, until you experience the things that Jason talks about you really can’t appreciate it. I’m certainly no technical savant, but I have seen the code supporting the things he’s discussing here. And it’s friggin insanely cool, elegant and robust. Let’s put it this way, if you’re perfectly happy with the way MODx is today, then that’s wonderful, as pretty much everything you’re accustomed to doing will continue to work. Just as fast as it does today. Only if you feel like taking advantage of a plethora of under the hood benefits that are also realized in his code (that exists today) you can. Stuff that fixes a lot of things on the bugtracker and requested in the forums:


                    • correct response headers
                    • better caching system
                    • proper recursive parser
                    • db-based sessions
                    • versioning
                    • unit tests (makes it easy to change things and make sure you don’t break others)
                    • consistent, documented, centralized API
                    • multiple contexts that support a single install for things like sub-domains, multi-language sites

                    This is by no means a comprehensive or definitive list of things to come. And just because Jason talks about things that sound (to me at least) intimidating and grossly different – even to the point that you might think it won’t resemble our beloved MODx of today – don’t let that scare you. I had the same exact reaction until I actually got to experience it. I’ve seen an unmodified 0.9.2.1 site (with custom plugins and modules) running with this code. The cool part is that it magically works with the same exact manager that’s in the SVN trunk today. (This does bring up the very real point of we’re in desperate need of a new manager.)

                    But let’s just say this: it IS the future, and the future is bright indeed.

                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                      • 27226
                      • 186 Posts
                      Sounds marvelous, Ryan! I hope we can share your experience with this hot stuff soon! laugh