We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16182
    • 56 Posts
    I’m using Ditto calls to create a sitemap.xml as described here http://svn.modxcms.com/docs/display/ADDON/YAMS+XML+Sitemap in the documentation. However, I don’t know how to use the Ditto filters to filter out monolingual pages in the loop and add them later in a separate call.

    In general, the documentation describes to process, but what filter do I need to include? Is there a filter for multi- vs. monolingual?

    I tried something like [tt]|content_en,,1[/tt] vs. [tt]|content_en,,2[/tt] which works on one of my test systems, but not on the production server. Any suggestions?
      • 16182
      • 56 Posts
      The way I solved it for me is as follows:

      I’ve defined an additional template variable "monolingual" of type number and default 0. I’ve attached this variable to my monolingual templates and set it to 1 there. Now I can filter for monolingual in the ditto call and exclude it inside the YAMS loop and do an extra ditto call outside the YAMS loop.

      While this works, I feel it is a bit cumbersome and error prone as it is easy to forget to set this variable when the YAMS settings are changed. It would be much nicer if YAMS could maintain a (hidden from the interface) variable that could be tested for monolingual vs. multilingual documents. How does YAMS actually know itself?
        • 22851
        • 805 Posts
        Hi Kongo09.

        Multilingual documents are those which have a template id that are in the list of multilingual templates specified at Modules>YAMS>Multilingual Templates. The monolingual documents are all the others.

        So you can exclude those templates that have a template id in the list of monolingual template ids. You can get these numbers from rows marked "No" in the table of templates at Modules>YAMS>Multilingual Templates.

        Then you can make a filter like [tt]&filter=`template,id1,2|template,id2,2|template,id3,2|...`[/tt]

        I don’t like this solution because you would have to update the snippet call every time you created a new monolingual template or made an existing one multilingual. However, the ditto filter syntax doesn’t seem flexible enough to do this programmatically... but maybe I am wrong.

        If you wanted to try then you might want to create a snippet called MultilingualTemplateList with the code:
        <?php
        require( $modx->config['base_path'] . 'assets/modules/yams/class/yams.class.inc.php' );
        $yams = YAMS::GetInstance();
        return $yams->GetActiveTemplatesList();
        ?>

        which will return a comma separated list of multilingual template ids and try to do something with that and an @EVAL within the ditto filter.
          YAMS: Yet Another Multilingual Solution for MODx
          YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
          Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
          • 16182
          • 56 Posts
          Thanks for the hint. So this does indeed seem to be a tricky one.

          I don’t know enough about the whole filter thing and @EVAL mechanics to do this (and it shouldn’t be that hard anyway). Unfortunately, the ditto documentation is also rather thin and cryptic.

          In the end I decided to rather develop the ditto code a bit further and introduced a new comparison mode that tests for the existance of variables. Find the hack here: http://modxcms.com/forums/index.php/topic,44012.0.html