We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14883 ☆ A M B ☆
    • 450 Posts
    The Revo documentation on @SELECT seems more-or-less unchanged from Evo (although I haven’t done a thorough comparison). @SELECT seems to be tied to MySQL syntax.

    So, I’m wondering, with all the effort put in to xPDO and database abstraction, is using @SELECT in Revo a gauche thing to do?

    And if so, what is the proper Revo alternative? Is it to use @EVAL and some sort of $modx->newQuery / $modx->getCollection blurb?

    I’ve tried to abstract this question to make it more globally useful; the specific binding I’m trying to do is get a list of all chunks of a particular category.
      • 22303 MODX Staff
      • 10,725 Posts
      Yes, using direct SQL is discouraged in Revolution. How about using a Snippet rather than @SELECT or @EVAL? Or does that not work for some reason in your scenario? If not we should research why it doesn’t and what it would take to make it work.
        • 14883 ☆ A M B ☆
        • 450 Posts
        Can I refer a snippet directly in the Input Option Values field of at TV? Without needing @EVAL? I haven’t came across anything on TVs that has informed me of that.

        All I’m doing is I have a main template and I want to create a TV with a dropdown list of content display options: essentially a list of various column layouts for the content. I’ve created a category called ’contentLayouts’ and created several chunks in that category with various <div> structures for various content layouts. So I just want to list (by name) all of the chunks in that category, so the page editor can pick the layout they want.


          • 14883 ☆ A M B ☆
          • 450 Posts
          Perhaps the documentation on @SELECT should be modified to convey the fact that this is a legacy/compatibility binding method and is not the preferred approach in Revo.
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: jrotering at Feb 11, 2010, 04:05 PM

            Can I refer a snippet directly in the Input Option Values field of at TV? Without needing @EVAL? I haven’t came across anything on TVs that has informed me of that.
            Likely not; I’m suggesting that if not, perhaps we should change that.

            Quote from: jrotering at Feb 11, 2010, 04:07 PM

            Perhaps the documentation on @SELECT should be modified to convey the fact that this is a legacy/compatibility binding method and is not the preferred approach in Revo.
            Agreed, but before we do that I want to make sure we have an alternative solution that is acceptable.
              • 14883 ☆ A M B ☆
              • 450 Posts
              It looks like this getChunks snippet will do exactly what I need.

              http://wiki.modxcms.com/index.php/Create_TV-Based_Chunks
                • 3749
                • 24,544 Posts
                There is some information here about how to get information from the DB in Revo snippets that might be of use to you: http://www.bobsguides.com/revolution-objects.html
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 32699 ☆ A M B ☆
                  • 427 Posts
                  Quote from: jrotering at Feb 11, 2010, 04:26 PM

                  It looks like this getChunks snippet will do exactly what I need.

                  http://wiki.modxcms.com/index.php/Create_TV-Based_Chunks

                  Try this instead:
                  http://www.shawnwilkerson.com/code/modx_revolution/modx_snippets/showChunk_snippet.html

                  Especially Lines 69-75, with the exception of line 74
                    Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

                    Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com
                    • 22827
                    • 129 Posts
                    I think this is a fairly common pattern that doesn’t have a straightforward implemention method in modx - straightforward for a dev to implement and a content editor can use.

                    I use this all the time for "side bars" in sites. I have a dedicated left and/or right hand side side bar, and I have a series of chunks that can be placed in those sidebars.

                    Problem:

                    How to set up modx in such a way that content editors can decide simply which chunks should appear in the side bars?

                    Solution:

                    As clunky as it is, the best way seems to be to put all of the sidebar chunks into a category.

                    In addition, create an "Empty" chunk with no content, for the cases where no sidebar chunk is required. Also a chunk called ’@INHERIT’ to allow parent chunk selections to be reflected in the child document sidebars.

                    Then create TVs:

                    SidebarPos1
                    SidebarPos2
                    SidebarPos3
                    etc


                    Each of these TVs is a dropdown menu, with the Input Option Values set to:

                    @SELECT name from site_htmlsnippets where category=’9’

                    (where category 9 is my sidebar chunks), and default set to @INHERIT

                    The template simply contains
                    {{[*SidebarPos1*]}}
                    {{[*SidebarPos2*]}}
                    etc
                    

                    For the developer, adding a chunk to the category is enough to make it available to a content editor, and the content editor can decide what chunks appear in what position on each page - with inheritance - with a simple dropdown TV.

                    This approach is simpler than the quoted http://wiki.modxcms.com/index.php/Create_TV-Based_Chunks, but still clumsy.

                    I realise revo is in RC now, but perhaps some consideration to a less clunky way of doing this in future releases could be considered.

                    Note that this is a direct analog of the ’module position’ in joomla, but a million times more flexible. When I first moved over to modx as my primary CMS, the first question I asked was how simulate this.
                      • 22303 MODX Staff
                      • 10,725 Posts
                      In Revo, you can create custom TV input types and widgets that could be used to address this in less clunky ways. But nothing in the core of MODx cares or wants to have anything to do with sidebars or any part of how you layout and organize a site. You will find we avoid as many analogs with Joomla! as possible. But seriously, the MODx approach to building sites without monolithic "modules" and/or "blocks" is an important one.

                      Anyway, the point of this thread though was simply alternatives to using @SELECT. IMO, using Snippets is preferable to @ bindings when you need to get direct access to dynamic data; we just need to add the ability to use these in the Template Variable input options.