We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24520
    • 14 Posts
    Workin with MODx I find that it’s very robust in certain areas. I have experience with other CMSes and coming from that background, there are few things I am either missing in MODx or don’t know how to implement. I would be grateful if someone could explain my issues.

    1. Components.

    This is something very important for my clients, especially for documentation and requirements. In typical documentation I specify templates and components. I divide templates into design templates (without Template Variables, using MODx terminology) and content templates (those using template variables) and also provide a list of components that could be embedded in specifed sections of those templates. I’m having some troubles of indentifying Component in MODx. Component for me is independent part of site, that has it’s own look, properties and logic handling. Such component can be put into template. So you can say that MenuBar is a component. Search is component. But also NewsList is component as well. Newslist would be a box with code that connects to a part of my site (let’s say /News), iterate through every page there (being a News item), gathering all the data, and presenting in it single list. I would also like to be able to control how many items I want to display - so my Component has properties.

    Is there something like this in MODx? Without Components, I don’t know how to start.
    - Chunks are parts of static code.
    - Plugins and Modules are something high-level, that influences behaviour of either whole site or manager section.
    - Are Snippets Components? As far as I know, those are code (php) + design (html), but do they have their own properties, that I could set via some interface, then read in code, and use?
    - Templates have own properties, could have logic (?) and own look, but then again I want to embed something INTO template. Can one template be embedded into other (that would be basically my Component then) and if yes, does that feel like a correct solution for what I want to achieve?

    2. Paragraph System

    I would like to have a part in my template (let’s say left column in three-column layout), that is empty, but allows user to put various components there - add them/delete/reorder - pretty much like in portal systems (like e107). I call this (from Day Communique) Paragraph System. I would like to specify what components can go into that paragraph system, and after that, user (well, author, admin) is free to manipulate within. Is there something like this in MODx, if not - is it possible to achieve this and how?

    Explanation highly appreciated.
      • 7231
      • 4,205 Posts
      Snippets == modules as you defined. snippets are basically PHP code which make them easy to develop. Together with the ModX API you can do virtually anything with snippets. You can include snippet calls within chuncks which will make blocks of html code that you can use in your templates.

      I did not understand point 2. But one of the main features in MODx are Template Variables which allow you to completely customize variables to use within your document. You could build a paragraph system using Template Variables to select what can be added in the side bar via check boxes, select lists etc... TV (as Template Variables are referred as).
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 24520
        • 14 Posts
        Snippets are modules exactly as I’ve defined? How do I define properties for single Snippet, then? I would like it to be exactly as for Template, using TV’s (properties for enduser, not for developer), but apparently I cannot? So I can see that snippets cannot have properties, which could be editable by author. This is really a standard feature for CMS, what I’m getting wrong here?

        I can see that Snippet+Chunk calling Snippet = "something like" Component, but without properties.

        "But one of the main features in MODx are Template Variables which allow you to completely customize variables to use within your document. You could build a paragraph system using Template Variables to select what can be added in the side bar via check boxes, select lists etc... " - well, not really. I could only build STATIC system, as I see it (please provide rough concept/sketch of how to do it if it’s possible). I would like to have a mechanism, that allows me to put my Components dynamically.

        Here is the image of an example (click for full view):



        As you can see, there are two columns in the template, and I can add/remove/reorder my Components within.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          But also NewsList is component as well. Newslist would be a box with code that connects to a part of my site (let’s say /News), iterate through every page there (being a News item), gathering all the data, and presenting in it single list. I would also like to be able to control how many items I want to display - so my Component has properties.
          That would be the Ditto snippet. Controls or properties (for most snippets) are handled by parameters:
          [!Ditto? &startID=`35` &display=`6`!]

          This would generate a listing of documents under document #35 in the Document tree, and show the first 6 documents retrieved, using the snippet’s default display template.

          http://ditto.modxcms.com/files/snippet-ditto-php.html

          You can also use the "Properties" tab to set various values for a snippet, but this does not have the flexibility of being configurable for different calls to the snippet. It is useful for such system-wide values as the path to the snippet files (usually /assets/snippets/snippet_name/), however.

          Some of the more complex snippets are now being developed to use a specified configuration file, so the only parameter necessary would be the location of the file. See the "config" parameter to Ditto, for example.

          Exactly how any given snippet is developed is basically up to the developer, however, and some "quick-and-dirty" snippets are very rudimentary, simply fulfilling someone’s immediate need, and kindly returned to the community in case someone else has the same need.

            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
            • 24520
            • 14 Posts
            I’m afraid you still don’t understand me. I know that every developer can organize his stuff within Snippet. But the functionality I have in mind is more related to general MODx design, not internal code of snippet.
            What I’m thinking of are properties for Snippet that are set exactly the same way as in Template (TV’s), and are unique for every instance of snippet on the page (not even template!). So in one page I can have 2 NewsLists, one showing 10 posts and one showing 3 posts, all configured by author. Passing parameters via POST/GET does not make sense in this scenario.

            NewsLists was just pure academic example, it could be any Component.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              So put the snippet tags in your content, they can go anywhere. And use different parameters for the different snippet calls. You can even put snippet tags in TVs, and edit the tags for each document’s TV.
                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
                • 22548
                • 58 Posts
                Hi there!
                You can definitely configure your template to have different versions of the same snippet, no problem with that. But I have the impression that your problem is also related to selling MODx to customers, who might be used to have something more than a list of parameters and placeholders they need to set up creatively (or have set up by you).
                If that is it, then I fear you will either have to limit them to the possibilities of QuickEdit, give them a thorough introduction into MODx or offer some level of support to them for a while.
                MODx doesn’t use Joomla-like components with restrained configuration possibilities: the parameter-placeholder magic combined with TV’s gives it just so much more flexibility.
                Just my beginner’s thoughts, never mind...
                Greets, Alex
                  • 30223
                  • 1,010 Posts
                  If I understand you correctly for you a component is a something that has:

                  • a pre-defined functionality such as a menu or document listing
                  • a (graphic) user interface to set properties

                  Snippets are very much like your components in functionality. But you need to let go of the expectation of a user interface for setting properties. Snippets are inserted in the document or template as special tags and it is within these tags that you normally set the properties. Your scenario of using the same component (ie snippet) twice on the same page but showing different content is entirely possible. Authors would be able to configure a NewsList exactly as you mention.

                  With a bit of forethought and a learning curve you can arrange a combination of Templates, Snippets and Template Variables (TV’s) to create a user interface for your authors.

                  Modx is a framework with a different approach and it does take a bit of getting used to. I’d suggest to let go of any expectations and try it out for a while. Once you get your head around it I’m fairly certain you’ll appreciate the enormous flexibility.
                    • 24520
                    • 14 Posts
                    Pachinko (Alex) got it right. That’s what I would like to have.

                    The post of TobyL sums up what I need. I know I can embed Snippet few times in my template. I know I can then pass properties to them.

                    The problem is that we understand "author" differently. You apparently see this role as someone who knows how MODx works internally (knows API) and know how to code. My definition is that it’s someone who has been given the preconfigured (with templates,snippets, etc) MODx, and would like to manage his Components thorough the site and set different properties to them. It would be impossible for such guy to dig into snippet/template and search for the exact code part that drives the properties change.

                    I understand that every CMS has its own concepts, thats why I am asking to get the full grip of the system. My current view is that while it’s quite good for developer, it lacks some additional functionality that authors might find very useful. As I understand QuickEdit is just a button that redirects author from the site view to the richeditor where he can edit "content". It would be supercool to allow for editing properties of snippets via QuickEdit as well. Not to mention changing order/adding/deleting dynamically. But that is of course a wish for a release far far away from today.

                    The best solution I could imagine right now with the knowledge I possess, is to :
                    - drop multiple instances of snippets (this was extreme example anyway)
                    - determine which snippets (Components) go where (statically)
                    - create as many different templates as I need - each with it’s own layout and design and set of Snippets
                    - create template variables for each Snippet, group them by Snippet and then embed into this particular template
                    - use those TV’s from within Snippets

                    Do I get it right? Is this possible?
                      • 22548
                      • 58 Posts
                      Hi rattkin,
                      I am definitely not the best person to give you advise on this being so far from finishing even my first MODx site myself, but I guess it would be best to preconfigure TVs with different design options (chunks), that make different snippet calls as described in: http://www.tiltedsymmetry.com/index.php?id=241. That way your customers would just have to decide by checkboxes in their articles. (Not sure if I got it right, though)
                      Greets, Alex