We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49148
    • 10 Posts
    Hello MODX'ers! Allow me to preface by stating that I'm a newb to MODX and admittedly very green, but also super excited by the possibilities it offers! I need a little advice, more philosophical than nitty-gritty really. I have a project for a non-profit that has multiple locations. I want to build a site that displays different data based on a url variable ala: example.com/los-angeles, example.com/sacramento etc. Not much would change between the locales (some graphics, and minor content), and would prefer to use the same file, and just pull the data from a separate table in the DB. My question is: At a high level, how would you set this up with MODX? Not looking for hand holding, just some overview / best practices sort of advice. Any help would be greatly appreciated!

    This question has been answered by sottwell. See the first response.

    • There are so many ways to accomplish this... it all depends on what you mean by "minor content".

      Probably the most extreme solution would be to have contexts for each "subdirectory", as described here https://github.com/chsmedien/XRouting

      A much simpler solution would be to have TVs, perhaps a MIGx multi-field grid TV, to handle the variations, and use the MODX resource tree structure to manage the subdirectory structure. Symlink resources can be used to pull content from the "main" resources, with the TV tags using the actual current resource's ultimate parent to determine which TV to display. Carefully planned naming conventions for the TVs and also for the paths to the images would make it easy.

      These are just what come to mind immediately, without a more clearly defined purpose.
        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
        • 49148
        • 10 Posts
        Thanks for the quick reply sottwell! I'll be reading up on MIGx, it looks on the surface to be a possibility for sure. To clarify a little more on what I'm trying to accomplish: The content that would change would be for the most part boiler plate stuff like address, staff, hours etc. But, would probably include a unique editable content area for events and what not. Ideally a site admin would be able to go in, fill out a group of variables (TVs via MIGx possibly?) and get a new location up and running. Thanks again!
        • discuss.answer
          Well, like I said before, there are so many possible ways to do this, the hardest part will be choosing one, then setting it up.

          I personally am very fond of MIGx, so that's definitely what I'd go with. The trickiest part would be how to generate the URLs, keeping in mind the need to keep it simple for the site admins. Possibly a Dashboard widget "Create a new location" that will automatically create the new top-level "parent" resource, plus add a Media Source, using the MIGx resource-based dynamic media source path snippet. Then redirect the admin to the editing page for the new top-level resource. Of course, this could also be a full-blown CMP, but since it's not going to be a really interactive feature, just doing some automated stuff based on a single input field (the region, which will be the pagetitle of the new resource) a Dashboard widget would be sufficient.
            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
          • And you can either use plain MIGx as a TV, or use MIGxDB and store your variable content in its own table. That would have an extra advantage of being easier to manipulate in custom snippets, as well as help in search features.
              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
              • 49148
              • 10 Posts
              Very much appreciated ma'am! I've got an avenue of attack smiley

              edit: I'm not a smart man wink [ed. note: philmayfield last edited this post 9 years, 2 months ago.]
                • 3749
                • 24,544 Posts
                Another simple way to do it if there's not that much different content is to set placeholders for the variable text and use a snippet in the template that checks the url and sets the placeholders accordingly.
                  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