We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38371
    • 42 Posts
    Hello to everyone,

    I am new to MODx, but I can certainly say that it is one of the most well-designed CMSs I've come across.

    My question stems from the fact that I have followed the Doodles Tutorial (both for 2.2.1 and 2.2.2+) and I have created some custom db tables which I can now manipulate. For example, I have created a table for Products and another one for Categories.

    I can use snippets to fetch my Products from the db along with their respective categories. All in all, it works fine.

    However, couldn't I just make the same thing by manipulating the Resource Tree. For example, if my Products were Posts and my Product Categories were Post Categories, then I would just have to right click the Resource Tree and create the respective categories and posts. It would just be a matter of Templates and TVs.

    So, I am asking everybody, why should someone prefer to create custom db tables over the already created Templates and their TVs?

    Is it for the flexibility of a custom db schema?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Resources are primarily intended to reflect the content of your site. Dealing with resources incurs a certain level of overhead that make it usually preferable to use custom tables to deal with data. For a small amount of data, using resources won't be a problem. But if you will have a lot of data (long lists of resources slowing down the Tree display), the data will change a lot (flushing the site cache and forcing re-generation of all the pages a lot) or you need to do a lot of manipulation of the data you'd probably be better off with custom tables. In the end, it's usually more of a personal decision to decide to what degree your custom data is pure data or is a kind of content, and to what degree your data will affect resource management.

      Besides, using custom tables certainly doesn't rule out using TVs to access them when your resources need the data.
        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
        • 3749
        • 24,544 Posts
        As Susan says, custom tables are better in every way except the difficulty of setting them up.

        With custom tables, both the front-end and the Manager will be significantly faster and the demands put on the server will be reduced substantially.


        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.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
          • 38371
          • 42 Posts
          Thank you very much for your answers.

          You have helped me reinforce my opinion. It is just the easiness in modification that Templates provide that has put me under this dilemma.

          For example, if I create a new category, all I need to do is create a new Document in the Tree.

          However, you're right. A custom db offers far more flexibility.

          Thank you very much for your answers.
            • 37044
            • 68 Posts
            Also the number and amount of data you were holding on each 'item' is a consideration. For example if you only had 10 products in 2 categories for ease it might make sense to make them as documents with TV's in the site tree.

            But obviously if you have 200 products in 30 categories managing that through TV's and documents would just be impractical!