We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16430
    • 217 Posts
    I am using snippet Getpage to show pages in parent folder
    [[!getPage?   &elementClass=`modSnippet`   &element=`getResources`  &parents=`[[*id]]`  
        &includeTVs=`1`   &tpl=`list` ]]

    Each page (room description) has TV containing type (single bed, apartmain, etc)
    I want to have form with checkboxes on the landing page so user can filter displayed output (only rooms with single bed or single and double beds, etc)

    I have no idea how can this be done...
      • 3749
      • 24,544 Posts
      You could put a custom snippet on the landing page that parsed the form data in the $_POST and used $modx->runSnippet() to call getPage and pass the correct properties through to getResources. I'm assuming that you meant that the checkboxes would be on the search page, not the landing page.

      I'd recommend testing all the possibilities with straight getResources calls first, to get the properties right before working on the custom snippet.

      That said, putting all your data in a custom DB table (or tables) and searching it with a custom snippet would be *way* more efficient. TV-based resource searches are very slow because the TVs aren't really indexed for that. [ed. note: BobRay last edited this post 12 years, 6 months ago.]
        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
        • 16430
        • 217 Posts
        I am not really good in PHP programing and it seems to be little bit complicated for me...

        Checkboxes would be on top of the page and underneath filtered results, so the page will look always the same but only displayed results (rooms) will change.
          • 3749
          • 24,544 Posts
          I wish I could tell you an easy way to do it, but if you're going to search based on what a user enters in a form, especially with multiple search criteria, I'm afraid you're going to have to learn some more about PHP (or hire a PHP programmer). wink

          I think it's theoretically possible to do what you want with FormIt, getPage, and getResources, but it would be very slow, and fairly difficult to develop.

          You could cheat somewhat by creating a getPage/getResources tag for every possible search and put each one on a separate page, then create a snippet that interpreted the checkboxes and forwarded the user to the appropriate page, but the search would still be fairly slow.

          Ideally, you'd create a custom database with all your data and use xPDO to do very fast searches on it and one resource to display the results (using a snippet and a Tpl chunk), but you'd have to learn more about PHP, xPDO, and database design first. [ed. note: BobRay last edited this post 12 years, 6 months ago.]
            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
            • 16430
            • 217 Posts
            I decided to do things simply...
            Created 3 more pages (single room, double room, apartment) and insert getresources snippet that should filter result according to TV (room-type) using TVFilters:

            [[!getPage? &elementClass=`modSnippet` &element=`getResources`  &parents=`7` &limit=`0` &includeTVs=`1` &tpl=`seznam`  &resources=`-31` &tvFilters=`room-type==single` ]]


            Resource -31 is page with this snippet.
            Each room has TV (input: list, output: text). But this snippet shows nothing.
            If I remove tvFilters property, it shows all pages.
            Dont know, where the problem could be...
              • 3749
              • 24,544 Posts
              That sounds like a good solution.

              I just guessing, but the hyphen in room-type might be an issue.

              Is the content of the TV actually just the word 'single'? You could look in the modx_site_tmplvar_contentvalues table in PhpMyAdmin to make sure.

              Also, make sure the TV is actually set. TvFilters won't respond to the default value. If you're going to use it, it's best not to have a default value for the TV.
                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
                • 16430
                • 217 Posts
                Indeed, for some reason it was not in modx_site_tmplvar_contentvalues at all. I saved different value and then saved "single" value again a it works... strange but thanks...
                  • 16430
                  • 217 Posts
                  Well simple solution is no more an option for me... Have to go back to original idea of multiple criteria filtering.
                  I am willing to pay for the working solution...
                    • 3749
                    • 24,544 Posts
                    Quote from: kudykam at Nov 15, 2011, 10:03 AM
                    Indeed, for some reason it was not in modx_site_tmplvar_contentvalues at all. I saved different value and then saved "single" value again a it works... strange but thanks...

                    That's because when the value is set to the default value, MODX doesn't bother to store it.
                      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
                      • 16430
                      • 217 Posts
                      I have found this:
                      http://www.kunane.com/modx/ditto-multiple-filters.html

                      which is exactly what I need, but it is written for Modx Evo.
                      Can anyone rewrite it to Revo please?