We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15083
    • 697 Posts
    Hi guys,

    I am going to be building a new Revo and had a few basic questions on the best way to approach the problem.

    1. I was to have a list of countries as resources.
    2. Inside these I want a list of mountain ranges.
    3. Inside the range I want a list of mountains.

    The potential is that there will be LOTS of the above, and the list could get very big.
    I was considering have a seperate template for each of the above with associated TVs. Users can add 2+3 above and a new resource and TV's would be created.

    My only fear is the manager will become fairly slow with the size of the document tree?
    Should I use custom DB table and objects for this?
    How do you add new resources and associated TV's in Revo, in Evo I just dropped records into the DB, is it the same now?

    Thanks in advance!!

    J
      • 33968
      • 863 Posts
      Definitely stick them in custom tables if you can. It will be much more efficient and you can put together some fairly simple snippets to list and filter your mountains as you need.

      Have a look here for some ideas how to build the tables, define relationships in a schema and construct a CMP to manage your data:
      http://rtfm.modx.com/display/revolution20/Using+Custom+Database+Tables+in+your+3rd+Party+Components
      http://rtfm.modx.com/display/revolution20/Developing+an+Extra+in+MODX+Revolution
        • 15083
        • 697 Posts
        Thanks for the reply.

        A CMP, a yes a manager page.
        Is Revo as flexible as Evo in terms of Manager pages...as in I can code the manager page up however I want as I would do a module in Evo?

        Think I followed this tutorial before, should be ok with it.
        Relationships are quite simple (I think/hope)
          • 15083
          • 697 Posts
          Another question please smiley
          I want the following url structure:

          /country/range/mountain - mountain template
          /country/range - range template
          /country - country template

          Obviously this is just the url structure, and the actual names will be used in the urls.
          The above will also be seperate DB tables and Revo objects.

          The question: Is the best approach to use the .htaccess to route the ruls above to a seperate modx page with the template + snippets to draw out that page? IE:

          /country/range/mountain => index.php?id=3 (etc etc)

          Is this how people usually accomplish furls without actually creating MODx resources for every country, every mountain etc etc.

          Also why would I not take this approach, and then use TV's to extend each template (IE the mountain template has all the TV's it needs for a mountain object??)

          Thanks again


            • 22303 MODX Staff
            • 10,725 Posts
            No, the better approach is to use a Plugin to route those via OnPageNotFound. This way you let MODX handle it's standard routing first, and then you delegate to the custom routing once that falls through. See https://forums.modx.com/thread/35476/can-snippets-plugins-make-use-of-intercept-friendly-urls?page=2#dis-post-194484 for an example.
              • 15083
              • 697 Posts
              I see.
              So in my plugin when a 404 is fired, I just redirect to a MODx resource with a snippet to handle?

              What about a normal 404...as in someone enters garbage, will MODx still serve up the standard 404 error page?
                • 22303 MODX Staff
                • 10,725 Posts
                Quote from: jusmeig at Sep 14, 2011, 10:37 AM
                I see.
                So in my plugin when a 404 is fired, I just redirect to a MODx resource with a snippet to handle?

                What about a normal 404...as in someone enters garbage, will MODx still serve up the standard 404 error page?
                To be concise, when MODX cannot find an appropriate Resource, it calls the $modx->sendErrorPage() method which fires the OnPageNotFound event. Your plugin is triggered on that event and you can do custom routing at that point however you want to. If you do not re-route the request in your plugin, then MODX will serve the appropriate error_page.
                  • 15083
                  • 697 Posts
                  Sweet, worked like a charm, TY. Used sendForward to preserve the pretty seo urls smiley

                  I have followed the article ShaunMc did for creating a table, XML schema and generating the model, however for more advanced stuff how do you:

                  Handle joins and relations? (Example: Pull out all the mountain ranges for a country and list them)
                  I would need a join table. In the past i'd just run a sql query against the DB and return a big array and work with it.

                  Can I run my own SQL queries in XPDO, and return an array or object? Is there something like CI's active record, and work it outside of creating an actual schema etc?