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

    I am a little confused as to the best way or the Modx way of doing the following:

    I want to present to the website visitor a listing of ’motels’ in a specific area.
    I want the list to include information regarding: name, address, telephone, and website.

    Now, I have done this before for another website that had a mysql database. I wrote a php query that was run when the website visitor clicked on the link associated with that request. The query read the db table AND ’selected’ the appropriate records based upon the criteria which was the particular ’clickable link’.

    Now, that means that I had a database table populated with the information requested.
    The query was run and produced the results which were displayed.

    Now, to modx.
    It seems that I can have a ’link’. When this link is clicked, it can send the visitor to another document/page that has the listing with details that I want to produce.
    To me this is saying I do not need a mysql db table named ’motels’ AND therefore do not need to write a ’snippet’ that will query the db table.

    If I have communicated clearly----
    Am I seeing this cleary?

    thanks
    geronimo
      • 4172
      • 5,888 Posts
      It seems that I can have a ’link’. When this link is clicked, it can send the visitor to another document/page that has the listing with details that I want to produce.
      To me this is saying I do not need a mysql db table named ’motels’ AND therefore do not need to write a ’snippet’ that will query the db table.

      you are right. you only have to create a new ressource in your ressource-tree -> ’motels’.
      Under this ressource create a ressource for each motel.
      For name you can use the field ’pagetitle’. For address, telephone, and website, photo and so on you can create Template-Vars. These are additional fields for ressources. For Detail-Infos you can use the field content.

      Then place a Ditto-call in your ressource ’motels’ for listing all motels. You can easy customize this listing with a chunk for the Ditto-items for example ’motelListing’ and use it in your Ditto-call like that: [!Ditto? &tpl=`motelListing` &display=`all`!] for example.
      Now you can have links to your motel-Detail-pages very easy. You need just something like that in your Ditto-chunk:
      <a href="[~[+id+]~]">[+pagetitle+]</a>

      This way you don’t need custom-tables or custom-snippets for this task and its very easy to modify your output for listings and detail-pages.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!