We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6841
    • 61 Posts
    Hey all you experts... I’ve been piddling around with MODx quite a bit the last few weeks, and I really like it, but I’m trying to really understand it better in order to be able to use it to its fullest potential. One of the things I’m struggling with right now is a clear understanding of all the resource types and when it makes sense to use each. I’ve read most of the Developer’s Guide, but I’m still struggling with some things.

    This is how I see it in my mind:

    • Chunks - Placeholders for stuff that needs to be repeated multiple times but doesn’t change a whole lot.
    • Snippets - Functions on steroids. Encapsulates some logic, accepts input via parameters, and produces some output which is inserted into the document.
    • Modules - Applications that run within the context of the MODx manager.
    Where I really struggle is seeing the distinguishing features (and, therefore, advantages and disadvantages) of plugins and TVs.

    Any enlightenment would be appreciated. Thanks.

    (...and thanks to the team for an awesome product!)
      Dave
      • 13577
      • 302 Posts
      Sure- I’ll take a shot at it wink

      TVs
      I used my first template variable when I needed a second column of editable content. With two "content" fields to work with, I could then drop them into a template in different places. I could also see this being of great worth when working with products. Say you want to have a template for your widgets. You could create price, weight, and size template variables so that when you make a new product page, you can enter that information in. Then your template formats it consistently. A very beautiful thing.

      Plugins
      I’ve not used a lot of plugins, but in essence, they allow you to attach behaviors to events. How’s that for jargon doublespeak! For instance, I recently had to create a plugin that fired when a page loaded to synchronize our University authentication system to the MODx user permissions system. I didn’t want the user to have to manually do this, so I created a function in PHP that I wanted to occur when a specific event happened. In this case, it was a page loading (OnWebPageInit). Now that happens automatically in the background and my users who log in thru the University automatically login thru MODx - I called it LogJam wink

      Hope those examples help a bit!
        Standard Disclaimer
        I could be totally wrong.
        • 28373
        • 204 Posts
        Quote from: jaredc at Apr 04, 2006, 08:06 PM


        TVs
        I used my first template variable when I needed a second column of editable content. With two "content" fields to work with, I could then drop them into a template in different places. I could also see this being of great worth when working with products. Say you want to have a template for your widgets. You could create price, weight, and size template variables so that when you make a new product page, you can enter that information in. Then your template formats it consistently. A very beautiful thing.

        Thanks jaredc, we haven’t got around to TV’s yet and the above is definately the best simplified explaination I’ve seen. It also answers the ’additional’ content fields as well, nice!
        • TVs are like a cross between a chunk (pure HTML code) and a snippet (pure php code). TVs can contain either; plain HTML code by default, then the @ bindings allow you to attach document content, chunk content, database query results, PHP code, and more.

          Assign your templates access to the TV and all documents using that template will get an extra editing input form so you can modify the TV for each document individually. You can also use the @INHERIT binding so that you can edit the TV for one document/folder, and all of its children will inherit the modified TV of their parent.

          And we haven’t even mentioned the built-in input and output "widgets" yet. For example, you can define the input method for each document as Rich Text or a plain textarea or text input, or a select dropdown or a radio button or a checkbox among others, while the output (what finally gets displayed on a page) can be an image, an HTML tag, or one of several javascript-powered widgets like tickers and scrollers.

          I’ve reached the point where there is never any content at all coded into my templates, only pure HTML layout tags containing MODx tags. All content is provided by various MODx tags, mostly TVs so the content can be modified on a page-by-page basis if desired.

          TVs multiply the power and flexibility of MODx by a considerable amount.

            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
            • 6841
            • 61 Posts
            Quote from: sottwell at Apr 04, 2006, 10:39 PM
            I’ve reached the point where there is never any content at all coded into my templates, only pure HTML layout tags containing MODx tags. All content is provided by various MODx tags, mostly TVs so the content can be modified on a page-by-page basis if desired.
            Susan, this sounds really awesome! Would you be willing to share an example or two of what you’re describing? If you have time, I’d love to see a complete example of some template code, some TV code, and a screenshot (or link to) what the user sees. If it’s a big hassle, don’t worry about it, but it would sure be a powerful learning tool for some of us up-and-comers!
              Dave
              • 28373
              • 204 Posts
              Quote from: sottwell at Apr 04, 2006, 10:39 PM

              TVs multiply the power and flexibility of MODx by a considerable amount.

              Thank’s Susan, that helps a lot in all honesty as newbie’s it’s like having a bunch of tigers on a leash and we’re finding it hard to resist letting them all loose at once - TV’s, needless to say, simply mind blowing shocked
              • I’ll explain two templates where I use TVs heavily.

                The first one is a very simple example that I called Pearl, taken from a potential client’s wholly Flash page, complete with annoying flickering and animated outlines and buttons with accompanying beeps and dings rolleyes (the client chose to go with somebody who would continue developing the rest of their site in Flash)
                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
                "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
                <head>
                <meta http-equiv="content-type" content="text/html; charset=[(etomite_charset)]" />
                <title>[(site_name)] ~ [*pagetitle*]</title>
                <style type="text/css">
                  @import url(assets/templates/Pearl/style/pearl.css);
                </style>
                <!--[if lt IE 7]>
                <script type="text/javascript" src="assets/js/ie7-standard-p.js"></script>
                <![endif]-->
                </head>
                <body>
                <div id="logo"></div>
                <div id="topmenu">[!DropMenu?startDoc=`81` &levelLimit=`1`!]</div>
                <div id="main">
                <div id="left">
                [*pearlMenu*]
                </div>
                <div id="right">
                [*#content*]
                </div>
                </div> <!-- end body -->
                <div id="footer">
                [*Footer*]
                </div>
                </body>
                </html>
                

                I thought about my document tree structure, and seeing that I would have four main menu categories with a variable number of items under those, I used the DropMenu call I would want to use for the majority of cases as the default value for the pearlMenu TV:
                <div id="leftmenu">
                [!DropMenu?startDoc=`[*parent*]`&levelLimit=`1`!]
                </div>
                

                Then for each of the four main menu document/folders, I edited the TV to override the default value ( I simply used a textarea for the Input type):
                <div id="leftmenu">
                [!DropMenu?startDoc=`[*id*]`&levelLimit=`1`!]
                </div>
                

                I didn’t need to do anything for the individual items under the main menu, since they would get the default TV value (laziness being one of the three cardinal virtues of the programmer).

                You can see the result here:
                http://www.alandaniel.co.uk/shells.html
                  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
                • Another beauty of TVs is that when you are using QuickEdit you can edit every TV attached to the page from the QuickEdit main menu, just as you can edit the main content.
                    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
                    • 6841
                    • 61 Posts
                    Thanks, Susan. That was very helpful. I did some playing with TVs last night, and I’m amazed! It great what you can do with this stuff. Do you know if anyone is actively maintaining the widgets? The DataGrid is awesome but could use a couple of enhancements.
                      Dave
                    • ddejc, please feel free to work on the widgets... smiley
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me