We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6726
    • 7,075 Posts
    I am encountering a problem with using multiple instance of Ditto (2.0.2 with 0.9.6 RC2).

    I have a page with multiple Ditto calls.
    The idea is to build a page listing with several categories, with each items belonging to that category listed under it. Funny things is, I have this kind of thing working on a website with Ditto 1 (at the time, you had to use tv prefix and &hiddentv).

    I imagine I could have used tags, but never used it thus I went for the "easy" solution : using a dropdown list TV to assign categorie to each item, then use Ditto filtering to sort each category under its title.

    Here is what I did

    Ditto calls :

    <h3>Les enfants</h3>
    
    <ul>[!Ditto? &id=`liste1` &parents=`190` &display=`all` &filter=`categorie_info_conseils,Les enfants,2` &tpl=`tpl_liste_info_conseils` &noResults=`Aucune info-conseils dans cette catégorie pour le moment`  &showPublishedOnly=`1` &hideFolders=`1`!]</ul> 
    
    <h3>Les pieges des ultraviolets</h3>
    
    
    <ul>[!Ditto? &id=`liste2` &parents=`190` &display=`all` &filter=`categorie_info_conseils,Les pieges des ultraviolets,2` &tpl=`tpl_liste_info_conseils` &noResults=`Aucune info-conseils dans cette catégorie pour le moment`  &showPublishedOnly=`1` &hideFolders=`1`!]</ul> 
    
     
    <h3>Les effets des surexpositions solaires et le depistage</h3>
    
    <ul>[!Ditto? &id=`liste3` &parents=`190` &display=`all` &filter=`categorie_info_conseils,Les effets des surexpositions solaires et le depistage,2` &tpl=`tpl_liste_info_conseils` &noResults=`Aucune info-conseils dans cette catégorie pour le moment`  &showPublishedOnly=`1` &hideFolders=`1`!]</ul> 
    
    <h3>Pour vous proteger</h3>
    
    <ul>[!Ditto? &id=`liste4` &parents=`190` &display=`all` &filter=`categorie_info_conseils,Pour vous proteger,2` &tpl=`tpl_liste_info_conseils` &noResults=`Aucune info-conseils dans cette catégorie pour le moment`  &showPublishedOnly=`1` &hideFolders=`1`!]</ul> 
    
    
    <h3>Les lunettes de soleil</h3>
    
    <ul>[!Ditto? &id=`liste5` &parents=`190` &display=`all` &filter=`categorie_info_conseils,Les lunettes de soleil,2` &tpl=`tpl_liste_info_conseils` &noResults=`Aucune info-conseils dans cette catégorie pour le moment`  &showPublishedOnly=`1` &hideFolders=`1`!]</ul> 
    
    <h3>Les cremes solaires</h3>
    
    <ul>[!Ditto? &id=`liste6` &parents=`190` &display=`all` &filter=`categorie_info_conseils,Les cremes solaires,2` &tpl=`tpl_liste_info_conseils` &noResults=`Aucune info-conseils dans cette catégorie pour le moment`  &showPublishedOnly=`1` &hideFolders=`1`!]</ul> 
    
    <h3>Bronzage</h3>
    
    <ul>[!Ditto? &id=`liste7` &parents=`190` &display=`all` &filter=`categorie_info_conseils,Bronzage,2` &tpl=`tpl_liste_info_conseils` &noResults=`Aucune info-conseils dans cette catégorie pour le moment`  &showPublishedOnly=`1` &hideFolders=`1`!]</ul> 
    
    <h3>En mer</h3>
    
    <ul>[!Ditto? &id=`liste8` &parents=`190` &display=`all` &filter=`categorie_info_conseils,En mer,2` &tpl=`tpl_liste_info_conseils` &noResults=`Aucune info-conseils dans cette catégorie pour le moment`  &showPublishedOnly=`1` &hideFolders=`1`!]</ul> 
    
    <h3>En montagne</h3>
    
    <ul>[!Ditto? &id=`liste9` &parents=`190` &display=`all` &filter=`categorie_info_conseils,En montagne,2` &tpl=`tpl_liste_info_conseils` &noResults=`Aucune info-conseils dans cette catégorie pour le moment`  &showPublishedOnly=`1` &hideFolders=`1`!]</ul> 
    
    


    And my ditto template is fairly simple :

    <li>[+texte_info_conseils+]</li>


    Instead of displaying list as expected, it just display the same list for each items, except the first one which only gets 2 records pulled.
    I used the debug console but I fail to make sense out of it...

    More probably than not, I have an understanding problem of the filter modes.
    At first I tried mode 2, then mode 8 : same result.
    I have tried cached and uncached calls : same result.

    I am guessing the issue is that placeholders with the same name can’t have multiple values... I have read Mark’s post about using ids for multiple calls but I am not sure how to make it work since you can’t prefix the ditto template placeholders with the unique id.

    To use multiple calls add &id=`unique name` to each Ditto call and then prefix all MODx (not Ditto template) placeholders with the id_. So for example if you had the id foo the pagination placeholders would all start with foo_ but the template placeholders like [+date+] would still remain the same.

    Any pointer ?
    Thanks !
      .: COO - Commerce Guys - Community Driven Innovation :.


      MODx est l&#39;outil id
      • 18397
      • 3,250 Posts
      Try modes 1 or 7.
        • 6726
        • 7,075 Posts
        Thanks Mark I’ll try that and report !
          .: COO - Commerce Guys - Community Driven Innovation :.


          MODx est l&#39;outil id
          • 6726
          • 7,075 Posts
          Hmmm, not sure I can use mode 1 and 7... they’re exclusive if I am not mistaken.
          I need to use the filter to match a given value... how do I do that with != and "Text not in field value" ?
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l&#39;outil id
            • 6726
            • 7,075 Posts
            Anyone can enlighten me on how I can do that with Ditto 2 ?
              .: COO - Commerce Guys - Community Driven Innovation :.


              MODx est l&#39;outil id
              • 18397
              • 3,250 Posts
              Can you please post the debug consoles of each call? Thanks,
                • 6726
                • 7,075 Posts
                As it happens, I rather have a problem with understanding and using filters with Ditto2 huh : it’s not multiple instance related, I tried to leave just one call and it doesn’t work better. I have tried mode 1 and 7 anyway but failed to achieve what I wanted.

                Attached is the debug file for the single occurence...
                And here is the url with debug on with the original posted code (multiple instance) :
                http://ns20999.ovh.net/~soleil/documents-et-actualites/infos-conseils.html

                Thanks Mark !
                  .: COO - Commerce Guys - Community Driven Innovation :.


                  MODx est l&#39;outil id
                  • 11975
                  • 2,542 Posts
                  Hi David,

                  Filters are powerful but their logical can be hard to get.

                  You have to keep in mind that filters are removing the documents from the result listing which match the criteria.

                  So if for instance you want to list all docs where parent is equal to 4
                  You have to write a filter which will remove all docs where parents are not equal to 4 and not a filter to get the docs where parent is equal to 4

                  So &filter=`parent,4,1`

                  Hope that helps

                  :-)
                    Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                    • 25663 MODX Staff
                    • 12,272 Posts
                    Maybe it should be called &filterOut to help with clarity?
                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                      • 6726
                      • 7,075 Posts
                      Of course it does thanks Helio !

                      It sure could be called &filterOut, especially since the old filter was working the opposite way and I have websites running Ditto 1 with simialr filters so I assumed it was working the same... Plus, it totally reverses the logic...

                      I’ll try edit my call and report.
                        .: COO - Commerce Guys - Community Driven Innovation :.


                        MODx est l&#39;outil id