We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6848
    • 52 Posts
    One feature I was missing with this perfect multilingual solution is to create "non symmetrical" sites.
    What I mean is to have the possibility to filter different documents in different languages.
    This is specially important when creating navigation.
    With ditto filters and using multilingual TVs this is not big issue.
    With Wayfinder the only way to filter (I know) is to use &excludeDocs.
    Here is (not very polished) snippet, which can be used for this:
    There are some ideas, taken from other posts in this forum, sorry than I don’t give explicit credits to the people
    <?php
    /**
     * Return Coma Delimited Children
     * Created by Dimitar Dimitrov 2009
     * Call like so:
     * 
     * [!ComaDelimitedChildren? &startID=`start parent id` &depth=`depth in the document tree` &tv=`tv name` &tvLang=`lang id` &filter=`value,mode`!]
     * 
     * Mode can either be 1 or  2. Mode 1 is not equal and mode 2 is equal. [2]
     */
    $startID = isset( $startID )? $startID: $modx -> documentObject['id'];
    $tv = isset( $tv ) ? $tv : "";
    $depth = isset( $depth ) ? $depth : "1";
    $tvLang = isset( $tvLang ) ? $tvLang : "";
    $tv=$tv.'_'.$tvLang;
    $flt = explode( ',', $filter);
    $value = $flt[0];
    $filtertype = isset( $flt[1] ) ? $flt[1] : "2";
    $ids = $modx->getChildIds($startID,$depth);
    $out=array();
    $condition='';
    foreach ($ids as $id) {
    	$condition='';
    	$tvarray = $modx -> getTemplateVarOutput( $tv, $id, $published = 1 );
    	$condition=$tvarray[$tv];
    	if ( ($filtertype == 1) && ($condition != $value)) {
    		$out[]= $id;
    	}
    	else if ( ($filtertype) == 2 && ($condition == $value) ) {
    		$out[]= $id;
    	}
    }
    $out[]='-1';
    $output=implode(',',$out);
    return $output;
    ?>
    

    Then call like this:
    [!Wayfinder? &startId=`3` &limit=`10` &excludeDocs=`[[ComaDelimitedChildren? &startID=`3` &tv=`available` &tvLang=`(yams_id)` &filter=`1,1`]]` &hideSubMenus=`TRUE` &outerTpl=`sub_menu_outer.wf` &rowTpl=`sub_menu.wf` &rowClass=`navButton` &hereClass=`currentSection` &lastClass=`last`!]


    and radio or dropdown TVs with name available_en available_fr available_bg would allow the menu produced bu WF to be different per language.




      • 22851
      • 805 Posts
      @ddim

      That’s great. Thank you very much for sharing!
        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.
        • 17883
        • 1,039 Posts
        Hi ddim,

        With ditto filters and using multilingual TVs this is not big issue.

        how does your solution look like? Do you have different Ditto-calls for each language? Then it is no problem, but how would a solution look like when there is only one ditto call for both languages?

        Thx for sharing!
          • 6848
          • 52 Posts
          Quote from: MadeMyDay at Nov 20, 2009, 04:52 PM

          Hi ddim,

          With ditto filters and using multilingual TVs this is not big issue.

          how does your solution look like? Do you have different Ditto-calls for each language? Then it is no problem, but how would a solution look like when there is only one ditto call for both languages?

          Thx for sharing!

          Hi,
          No I have single ditto calls. An example of filtering using the same TV is:

          [!Ditto? &id=`(yams_id)_footer` &extenders=`@FILE assets/modules/yams/yams.extender.inc.php` &parents=`112` &total=`8` &tpl=`footer.dt` &tplCurrentDocument=`footer-current.dt` &tplLast=`footer-last.dt` &orderBy=`menuindex ASC` &filter=`hidemenu,1,2|available_(yams_id),1,1` &hideFolders=`0` &debug=`0`!]


          see the second part of the filter "available_(yams_id),1,1"
            • 17883
            • 1,039 Posts
            Thank you very much! Have to get used to (yams_id) as a placeholder in the Ditto-Calls ;-)
              • 6848
              • 52 Posts
              One small issue with using the snippet is if you want to combine it with other ids in &excludeDocs. For example with this construct:

              &excludeDocs=`10,11,36,[[ComaDelimitedChildren? &startID=`[[UltimateParent]]` &tv=`available` &tvLang=`(yams_id)` &filter=`1,1`]]`
              


              you will have a problem because in case the snippet returns nothing in the SQL query you will have something like: "... not in (10,11,36,)..." which will lead to SQL error.

              To solve this, in the snippet add one more element to the array of IDs which can never be found. For example before the implode call add $out[]=’-1’:

              ....
              $out[]='-1';
              $output=implode(',',$out);
              return $output;
              



                • 22851
                • 805 Posts
                @MadeMyDay.

                If you want to manage a single Ditto call, then rather than placing one copy in each language’s content field you could place it in a chunk, or you could place it directly in the document template.

                @ddim

                Don’t forget that if you have the appropriate ditto language files available you should also be able to add: &language=`(yams_mname)` to your call so that, for example, the ’no results’ text appears in the correct language.
                  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.
                  • 6848
                  • 52 Posts
                  Quote from: PMS at Nov 24, 2009, 09:29 AM

                  @MadeMyDay.

                  If you want to manage a single Ditto call, then rather than placing one copy in each language’s content field you could place it in a chunk, or you could place it directly in the document template.

                  @ddim

                  Don’t forget that if you have the appropriate ditto language files available you should also be able to add: &language=`(yams_mname)` to your call so that, for example, the ’no results’ text appears in the correct language.

                  Yes, of course, simply in this example I didn’t need the language, because it never returns ditto language texts. But this is specially important with pagination, dates formatting and so on.
                  I would say that it is good style to allways put &language=`(yams_mname)` in the call.

                  Below is an example of news listing, which formats the date according to the language:

                  [!Ditto? &id=`(yams_id)_listnews` &language=`(yams_mname)` &extenders=`@FILE assets/modules/yams/yams.extender.inc.php` &total=`10` &tpl=`listnews.dt` &orderBy=`datepublish DESC` &hideFolders=`1` &debug=`0` &dateSource=`pub_date` &dateFormat=`%d %B %Y`!]


                  May be a bit off topic, but one remark about the dates - to have proper date outputs, don’t forget to set the locales properly. With ditto this can be done in the language file. Add something like this to it:
                   $loc = setlocale(LC_TIME, 'bg_BG.utf-8'); 



                  And related to the usage of "navigation" snippets like wayFinder and ditto - I’m trying to use them mainly inside templates. In very rare cases (like sitemap pages) I’m using such calls in the pages.

                  All the examples above can be seen in action at http://bbr.nitbg.com. In the next days this will be transferred to a live site at http://www.bbr.bg