We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25458
    • 1 Posts
    Let me start by giving a little background on the issue, so hopefully it will be more clear what I am trying to accomplish. I recently developed a site that required a listing of distributors in the U.S. broken down by state (one actual web page per state). I implemented by going through the rather drawn out process of creating 51 new documents in ModX and adding the appropriate content to each one.

    What I would like to have done is simply store this information in a database and retrieve all the records for a particular state on page load. I believe that I have figured out how to actually integrate the database via the DBAPI, but my block is coming in trying to figure out how to dynamically fetch the page.

    For instance, let’s say I click a link for distributors in Texas. For this example, we’ll say the page is named something like distributors-texas.html. Only, there is no real page. Instead, I would only have a distributors page, which would accept the ’texas’ part of the link and pull the appropriate information from the database. I’m just not sure how to get ModX to do this. Any ideas?

    Thanks in advance.
      • 33372
      • 1,611 Posts
      Well, there are probably fifty ways that you could do this, so it’ll be interesting to see the different responses you get. If you really want your URLs just the way you indicated, then I guess I would use .htaccess (or a weblink for each state or MODx plugin if you prefer, although that would change the URL shown in the browser’s address bar) to redirect distributors-texas.html to distributors.html?state=texas. Then just have a snippet on your distributors page that uses the state from the $_GET array to do its thing.
        "Things are not what they appear to be; nor are they otherwise." - Buddha

        "Well, gee, Buddha - that wasn't very helpful..." - ZAP

        Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options