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

    I’m relatively new to MODx, and so far I’m absolutely loving it. It’s a great CMS and it’s very easy to develop sites.

    I have however come across what would seem to be a very simple problem (I could do this in minutes working with just HTML, PHP and MySQL), yet I’ve spent many hours trawling for a solution and cannot seem to work it out. I’m sure it’s a simple solution, but I just can’t work it out.

    The problem I have is this - I want to display content on a page (document) based on the results of a query to a different MySQL database to where modx is installed. So what needs to happen is this:

    1) User selects a month from a drop down box and click "submit"
    2) This value is passed to a snippet which runs a query with the parameter value passed from the select box in the WHERE statement
    3) Query results are displayed on the page

    I can write the PHP to create the recordset and display it on the page, but where I’m struggling is how to generate the parameter and pass this into the snippet.

    The way I would "normally" do this (without a CMS) would be to produce a form with a select box, with the values and labels dynamically produced by a query. The user then selects the correct option, clicks submit, and the page refreshes with the results of the query shown.

    I’m open to other methods of doing this. All I really need to achieve is to have a user select a month and the query return all the valid results from a table where the event happens in that month.

    Can anyone help before my brain explodes?

    Many thanks in advance,


    Jon
      • 30789
      • 2 Posts
      I’ve managed to work this out now. It was simply a case of not getting my head around the architecture properly. Apologies for the silly question!
        • 7231
        • 4,205 Posts
        It is more often a matter of unlearning what you have picked up from other CMS and basically doing it the way you would do it without a CMS.

        Basically put your scrip[t in a snippet and make the snippet call uncached [! !] to make sure it gets the live data rather than from the cache.

        Also try to make use of the MODx api whenever possible since it will save time: see the community wiki:
        http://wiki.modxcms.com/index.php/Category:API
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don't know what it is.
          Do you, Mr. Jones? - [bob dylan]