We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27302
    • 154 Posts
    Does anyone know of any links to a tutorial or method as to how to link Ditto results shown on a page to input given on a dropdown list or an option?

    I am building a list of items that are based upon the counties in the UK, so there are quite a number of them and it would be impractical to build separate pages with separate Ditto filters.

    Each item would be an individual page/resource and I would attach a TV to them so that the website editor can select a country/state and other options to be associated with that page/resource. I would then like a page that displays all results, but at the top of the page options for the user to select, such as the county/State perhaps alongside other options and then have Ditto dynamically list results based upon those options.

    I can’t seem to figure out a way to do this without having to build a separate page/resource for each country/state or option. I am also not sure how to pass a value given from a dropdown list or form to Ditto so that it can filter the results.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Use a snippet with $modx->runSnippet(’Ditto’, array(’filter’->’<filter-string’, ...));
      and use a variable to set the filter criteria in the filter string.
        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
        • 27302
        • 154 Posts
        Hi Sottwell,

        Thanks. Though because I am not a programmer, could you clarify the snippet. Do I just create a snippet with simply $modx->runSnippet(’Ditto’, array(’filter’->’<filter-string’, ...)); ? Sorry for sounding stupid. I never did get on with programming at college! smiley
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          No. As usual, the ... indicates "etc etc ... ". If you aren’t at all familiar with coding, then you’ll not be able to do this. Some things are simply too unusual or too complex to just be "out-of-the-box". With no programming skills, I’m afraid you’ll either need to get someone else to do it for you, or simply build sites within your skill set.
            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
            • 27302
            • 154 Posts
            Surely there is a ready made solution or a simple way to pass parameters to Ditto? What I’m needing isn’t unusual as it is very similar to the filter by price range of products or "list by popularity" at Amazon.com. It looks like there might be something similar on the ModX Extras homepage to select the version of ModX to search for extras for.

            I have found one guy that looks like I could modify the method for to do what I want.
            http://www.gregorysmart.com/2009/07/03/a-modx-ditto-directory/

            I just might have to do it a cumbersome way.

            Perhaps I could create a dropdown TV for the resources, but use this as keyword tag selector with Ditto somehow and have the tags displayed as a dropdown rather than a straight list of words?
              • 27302
              • 154 Posts
              It appears that Ditto can do what I require without any additional snippets or PHP. This guy has done it. But he doesn’t explain how to make the form fully.

              http://translate.google.com/translate?js=y&prev=_t&hl=en&ie=UTF-8&layout=1&eotf=1&u=http%3A%2F%2Fmodx.ru%2Fblog%2F409%2F&sl=ru&tl=en

              Does anyone any suggestions?
                • 26931
                • 2,314 Posts
                It appears that Ditto can do what I require without any additional snippets or PHP. This guy has done it. But he doesn’t explain how to make the form fully.
                http://translate.google.com/translate?js=y&prev=_t&hl=en&ie=UTF-8&layout=1&eotf=1&u=http%3A%2F%2Fmodx.ru%2Fblog%2F409%2F&sl=ru&tl=en
                Does anyone any suggestions?

                read that article too ... tweaked it a little bit: http://bit.ly/bgx7dX

                and for advanced filter possibilities you could use tvExplorer: http://modxcms.com/forums/index.php/topic,16456.0.html
                  • 27302
                  • 154 Posts
                  Sharkbait, that was absolutely perfect, really much appreciated, thanks!! smiley smiley smiley
                    • 27302
                    • 154 Posts
                    Sharkbait, the filter works absolutely brilliantly. But I have one problem. When I click on the link to the page I want to view after I have performed a search I get this message

                    « MODx Parse Error »

                    MODx encountered the following error while attempting to parse the requested resource:
                    « PHP Parse Error »

                    PHP error debug
                    Error: strpos() [function.strpos]: Empty delimiter
                    Error type/ Nr.: Warning - 2
                    File: /home/epcouk/domains/5ep.co.uk/public_html/ukactive/assets/snippets/ditto/classes/filter.class.inc.php
                    Line: 81
                    Line 81 source: if (strpos($value[$this->array_key], $this->filterValue)===FALSE)

                    Even if I move the resource to a different container and try to preview the page directly I get this error too.
                      • 27302
                      • 154 Posts
                      Hmm. Odd. The parse error seems to occur when I deactivate one of the TV’s that I had associated with the template.