We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22827
    • 129 Posts
    Quote from: OpenGeek at Mar 08, 2010, 07:13 PM

    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.

    Of course it doesn’t - the sidebar example was just that - an example of where a content editor can select from a number of chunks for a particular position on a page, where a @SELECT is seemingly the best approach even though it is a MODx table being queried.


    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.

    Yes, Joomla! is hideous, thats why we came here. The sidebar example was one where we may wish to have a block because that is what the site design warrants - this is why there are wiki entries and several threads regarding it.


    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.

    The reason why I detailed this example (and because the OP also decided that it wasn’t just @SELECT but specifically querying MODx tables) is because I assume that where possible, the modx design would prefer that modx objects such as chunks would be accessed via a more rigorous API (like $modx->getChunkNames([category]) for example) than via xPDO or querying modx tables directly. This allows for a better upgrade path.
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: paulkoan at Mar 08, 2010, 08:02 PM


      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.

      The reason why I detailed this example (and because the OP also decided that it wasn’t just @SELECT but specifically querying MODx tables) is because I assume that where possible, the modx design would prefer that modx objects such as chunks would be accessed via a more rigorous API (like $modx->getChunkNames([category]) for example) than via xPDO or querying modx tables directly. This allows for a better upgrade path.
      xPDO provides the consistent API that protects your upgrade path and abstracts direct database access. So enabling the use of xPDO/MODx API calls in Snippets (or interpreting any MODx tags) in the input options is all we are discussing here.
        • 22827
        • 129 Posts
        Quote from: OpenGeek at Mar 09, 2010, 09:35 AM

        xPDO provides the consistent API that protects your upgrade path and abstracts direct database access. So enabling the use of xPDO/MODx API calls in Snippets (or interpreting any MODx tags) in the input options is all we are discussing here.

        Quote from: jrotering at Feb 11, 2010, 03:52 PM


        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.

        Err - the OP is discussing methods of accessing lists of chunks in a category. That is what is being discussed here as much as anything. Yes the general for SQL access would be solved by xPDO access via TV inputs - but the more specific case of accessing modx objects such as chunks to develop dynamic TVs based on chunks or documents?

        It would be good if API calls could be made from TV inputs also...

          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: paulkoan at Mar 09, 2010, 04:46 PM

          Err - the OP is discussing methods of accessing lists of chunks in a category. That is what is being discussed here as much as anything.
          Er, well, the topic is "Is @SELECT bad form in Revo?" and I am suggesting that yes it should be considered bad form. In addition, I was identifying what needs to be done so that we can remove our dependence on it in the near future, i.e. address the access it provided historically, such as this one example.

          Quote from: paulkoan at Mar 09, 2010, 04:46 PM

          Yes the general for SQL access would be solved by xPDO access via TV inputs - but the more specific case of accessing modx objects such as chunks to develop dynamic TVs based on chunks or documents?
          MODx is xPDO extended, so maybe you are just not understanding that the same methods are used to access any xPDO-based object. MODx provides some extra methods related to the CMS domain, but for all intensive purposes you are using the xPDO API when you do anything with the MODx Core in Revolution.

          Quote from: paulkoan at Mar 09, 2010, 04:46 PM

          It would be good if API calls could be made from TV inputs also...
          That’s what a Snippet provides, the ability to call API methods, so yes, that is what I am suggesting by allowing MODx tags to be processed inside these values.
            • 22827
            • 129 Posts
            Quote from: OpenGeek at Mar 10, 2010, 06:17 AM

            Quote from: paulkoan at Mar 09, 2010, 04:46 PM

            Err - the OP is discussing methods of accessing lists of chunks in a category. That is what is being discussed here as much as anything.
            Er, well, the topic is "Is @SELECT bad form in Revo?" and I am suggesting that yes it should be considered bad form. In addition, I was identifying what needs to be done so that we can remove our dependence on it in the near future, i.e. address the access it provided historically, such as this one example.

            Heh, I *know* you are not suggesting that the topic title means that no other aspects of the OP should be discussed right?

            Quote from: paulkoan at Mar 09, 2010, 04:46 PM

            Yes the general for SQL access would be solved by xPDO access via TV inputs - but the more specific case of accessing modx objects such as chunks to develop dynamic TVs based on chunks or documents?

            MODx is xPDO extended, so maybe you are just not understanding that the same methods are used to access any xPDO-based object. MODx provides some extra methods related to the CMS domain, but for all intensive purposes you are using the xPDO API when you do anything with the MODx Core in Revolution.

            I see what you are saying - the MODx CMS API just wraps around xPDO to get to the underlying data objects, so if we want to access modx CMS objects, then we may just as well use xpdo directly rather than the modx CMS API - ie treat the modx tables and objects like any other data access.

            This is a little different to the approach I normally take, which is to avoid direct access to MODx (or any other system) tables whereever possible (including via an ORB), instead preferring the highest level API provided. My reasoning is that the modx API provides a ’contract’ - where if I ask the API to get something or set something, it will do it, and how it does it isn’t relevant to me. So if down the line, a dramatic change was necessary to the object model, tables, or anything else abstracted by the API, the MODx API would still just do its job and my code would still work.

            But I appreciate that the API cannot abstract everything I would ever want to do, and so xpdo is certainly a lot better than direct SELECTs.


            Quote from: paulkoan at Mar 09, 2010, 04:46 PM

            It would be good if API calls could be made from TV inputs also...

            That’s what a Snippet provides, the ability to call API methods, so yes, that is what I am suggesting by allowing MODx tags to be processed inside these values.

            A snippet as a TV input would add an extraordinary level of flexibility to TVs - it would be a great addition.
              • 3749
              • 24,544 Posts
              But I appreciate that the API cannot abstract everything I would ever want to do, and so xpdo is certainly a lot better than direct SELECTs.

              Don’t misunderstand, there’s still a MODx API and you’re encouraged to used it, but much of it is based on subclassing xPDO objects. In fact,

              <?php
              class modX extends xPDO {
              ...
              } 
              
              class modResource extends modAccessibleSimpleObject {
              }
              
              class modAccessibleSimpleObject extends modAccessibleObject {
              }
              
              class modAccessibleObject extends xPDOObject {
              ?>


              So most of the API methods are actually inherited from xPDO. There’s a short introduction to some of the new API objects and methods here: http://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
                Don’t know how accurate this is, but at the least its an interesting view of xPDO (so it says -- looks more like the MODx API):
                http://wheel.webprogramming.ca

                I also took the liberty to create a sanitized version of the MODx core dumped:
                http://www.shawnwilkerson.com/code/modx_revolution/revolution_environment.html

                I did this, due to growing weary of looking at all of the deprecated code, while trying to learn the API. Its huge, so give it a few seconds to format.
                  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