We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22533
    • 41 Posts
    Bonjour à tous,

    Quelqu’un aurait-il déjà utilisé le mot clé @CODE pour Ditto?

    J’essaie en vain de l’utiliser depuis tout à l’heure, et c’est très dur de faire des recherches sur le forum ou ailleurs car rien ne prend en compte le @ ! >:(

    La seule page que j’ai pu trouver (http://wiki.modxcms.com/index.php/Fr:Snippets:Mon_premier_snippet) et qui dit quelque chose de différent de "Si il n’y a pas @CODE ou @FILE, alors c’est le nom d’un chunk qui est utilisé" indique un exemple qui ne fonctionne pas :
    [!Ditto? &parents=`8` &randomize=`1` &total=`1` &tpl=`@CODE[+content+]` !]


    Le but est évidemment de l’utiliser pour les arguments &tpl, &tplFirst, &tplLast

    Comme je compte faire de nombreux appels différents à Ditto, tous formattés différemment, j’aimerais éviter de créer trop de chunks différents, pour ne pas m’y perdre...

    J’ai essayé de nombreux appels, tous sans succès :
    &tpl=`@CODE[+content+]`
    &tpl=`@CODE [+content+]`
    
    &tpl=`@CODEtoto`
    &tpl=`@CODE toto`
    
    &tpl=`@CODE<li>[+longtitle+]</li>`
    &tpl=`@CODE <li>[+longtitle+]</li>`
    
    &tpl=`@CODE echo 'toto'`
    


    Si vous pouvez me venir en aide, je vous en serais très reconnaissant! wink



    Autre point sur Ditto, tant qu’à faire :

    Quelle différence (en termes de résultat bien sûr) entre "querylimit", "display" et "total"?

    Par exemple, querylimit ne va-t-il pas ramener des résultats partiels si le nombre de docs exploré est très important?

    Pour faire simple : lequel est le meilleur? grin

    Merci encore!
      • 10449
      • 956 Posts
      Sorry for not replying in french :|

      I guess that the = character is illegal in snippets ("?" too, if I’m not mistaken). At least you’ll get errors when using this:

      [!Ditto? &parents=`81` &total=`100` &tpl=`@CODE <a href="[~[+id+]~]">[+pagetitle+]</a><br />` &debug=`true`!]
      


      However, this works:
      [!Ditto? &parents=`81` &total=`100` &tpl=`@CODE [+pagetitle+]<br />` &debug=`true`!]
      


      (tested with 0.9.6.)

      [!Ditto? &parents=`15` &total=`100` &tpl=`@CODE [+content+]<hr />` &debug=`true`!]
      

      ^ works as well here...


      I would recommend to store Ditto templates in chunks. I personally never used @CODE in Ditto calls.
        • 22533
        • 41 Posts
        Quote from: ganeshXL at Dec 12, 2007, 07:57 PM

        However, this works:
        [!Ditto? &parents=`81` &total=`100` &tpl=`@CODE [+pagetitle+]<br />` &debug=`true`!]
        

        (tested with 0.9.6.)
        It doesn’t work for me huh
        I’ve put this exact code with the parent I want, and yet I get the message :
        &tpl either does not contain any placeholders or is an invalid chunk name, code block, or filename. Please check it.

        Quote from: ganeshXL at Dec 12, 2007, 07:57 PM

        I would recommend to store Ditto templates in chunks. I personally never used @CODE in Ditto calls.
        In fact this would be for my home page. I’d like to have at least 5 or 6 ditto calls, and templating will certainly be different for each of them.
        But I may review my position considering your advice.
          • 10449
          • 956 Posts
          Weird. I just now tested in on my local WinXP machine with XAMPP and MODx 0.9.6.1. Works here as well.

          Which MODx and Ditto version do you have?
            • 22533
            • 41 Posts
            Sorry, I use 0.961, with Ditto 2.0.2

            I just tested again
            - Simple Ditto call with a chunk => OK
            - Excat same Ditto call with &tpl=`@CODE [+pagetitle+]
            ` => KO

            My website is online, I don’t know if it makes any difference, but I’ll try tonight on my local computer... and give you my results.
            Anyway, I think I’ll go on with chunks even if it stresses me a little... tongue


            By the way, on another Ditto call, I’m trying to use the filter parameter to exclude the starting point.
            Indeed, I’d like to display all the last documents updated on the site, except the home page (id = 1) where the call is made :
            &filter=`id, [*id*], 1`

            This code above doesn’t work, however, the one below does (but it doesn’t exclude the parent with id=1 because of the "greater or equals" clause) :
            &filter=`id, [*id*], 6`


            I think because I exclude the parent with the first code, all the children are also excluded...
            I know I can do what I want with other ways, for example "&documents", but if you have a solution for that point too, it’ll be great !


            PS : Désolé, je sais qu’on est sur le forum français... Peut-être puis-je retraduire le premier post pour qu’un modo le déplace dans une section anglaise?
              • 11975
              • 2,542 Posts
              Salut,

              grin c’est un thread multilingue

              Pour filter enlève les espaces entre les termes
              &filter=`id,[*id*],2` => enleve les documents dont l’id est égale à l’id du doc courant.
              Pour les filtres Ditto procède par élimination pas par correspondance.

              :-)

                Made with MODx : [url=http://www.copadel.com]copadel, fruits et l