We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14404
    • 84 Posts
    ((yams_data:[+id+]:content_en))
    


    Gives the same result.. so what can i do more about this except for adding the pages for the other languages?


    -edit-

    Btw, ((yams_data:’ID NUMBER’:content_en)) does work.. but then i need to add this manual for every doc :/
      • 22851
      • 805 Posts
      Sorry. My logic was flawed. Ditto does not evaluate the content of the source template variable... It just outputs it. So the [+id+] still gets evaluated in the context of the Ditto call document rather than the source document - so same problem as you say.

      I don’t have a solution for you I’m afraid. The only two options I can think of are the ones you have already discovered: 1) Hard-wire the [tt]id[/tt] in [tt]((yams_data:id:content_en))[/tt] for every document, or 2) translate/copy the content for every document from English to Dutch.
        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.
        • 14404
        • 84 Posts
        Hmm ok, too bad haha..

        Do you know if there is something like a button to synchronise the fields?

        So like, make a TV for every document with the button: "Syncrhonise from English"?
          • 22851
          • 805 Posts
          Quote from: Joeeeeh at Mar 22, 2010, 05:18 AM

          Do you know if there is something like a button to synchronise the fields?

          So like, make a TV for every document with the button: "Syncrhonise from English"?

          In my opinion, the best solution would be a ManagerManager rule, but unfortunately it currently doesn’t support synchronising one TV with another (unless it has happened very recently and I haven’t noticed). Someone else has already requested this feature, so you could register your support for it too. If you are lucky then it might be in the next release.

          The only remaining option is to write a custom plugin that will synchronise the fields on document save.
            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.
            • 22851
            • 805 Posts
            Looking at that MM feature request, it looks like ’template variable’-’document variable’ synchronisation works. If ’document variable’-’template variable’ also works, then you might be able to achieve what you want in two steps. You could try placing something like this in your mm_rules:

            mm_synch_fields('content_en,content');
            mm_synch_fields('content,content_nl');
              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.
              • 14404
              • 84 Posts
              Ok thank you!

              1 small question about this. Will it always sync. or only when empty?
                • 22851
                • 805 Posts
                The ManagerManager rule would always synch, not just when the destination field is empty.

                Okay, so that has reminded me that when a default value is set for the template variable as you have been doing this only has effect until the field is modified. In that way by default all languages show the default language (English in your case), until you add a translation. It’s such a shame that this approach doesn’t work well with Ditto.

                In that case the only solution I can think of is a custom plugin that works on the OnBeforeDocFormSave event. The following is completely untested, but it might just work... Use at your own risk! You’ll have to create a new plugin called YAMSUseDefaultLanguageWhenEmpty or perhaps something more elegant, set it to be active on the OnBeforeDocFormSave event and use the following code:

                // Get the current document id
                $evt = &$modx->Event;
                
                switch ( $evt->name )
                {
                  case 'OnBeforeDocFormSave':
                  
                    // We'll need to access the MODx template variables array...
                    global $tmplvars;
                    
                    // Loop over all the fields that should be synchronised
                    $fieldsToSynchronise = array(
                      'pagetitle'
                      , 'longtitle'
                      , 'description'
                      , 'introtext'
                      , 'content'
                      , 'menutitle'
                      );
                      
                    // Get the current document id
                    $docId = $evt->params['id'];
                    
                    // Instantiate YAMS
                    require_once( dirname( __FILE__ ) . '/class/yams.class.inc.php' );
                    require_once( dirname( __FILE__ ) . '/yams.module.funcs.inc.php' );
                    
                    $yams = YAMS::GetInstance();
                    
                    // Get the default language id
                    $defaultLangId = $yams->GetDefaultLangId();
                    
                    // Check if the current document is multilingual
                    $isMultilingualDocument =
                        $yams->IsMultilingualDocument( $docId )
                        || $yams->IsMultilingualTemplate( $template );    
                        
                    while ( $isMultilingualDocument )
                    {
                      // Loop over all language ids except the default one...
                      foreach ( $yams->GetActiveLangIds() as $langId )
                      {
                        if ( $langId == $defaultLangId )
                        {
                          continue;
                        }
                        
                        foreach( $fieldsToSynchronise as $field )
                        {
                          // Calculate the tv name
                          $tvName = $field . '_' . $langId;
                          
                          // Get its id...
                          $tvId = YAMSGetTempVarId( $tvName );
                          if ( $tvId === FALSE )
                          {
                            continue;
                          }
                          
                          // Get its identifier...
                          $tvIdentifier =
                            YAMSTVDataToMMName( $tvName, $tvId, '' );
                          if ( ! array_key_exists( $tvIdentifier, $tmplvars ) )
                          {
                            if ( ! array_key_exists( $tvName, $tmplvars ) )
                            {
                              continue;
                            }
                            else
                            {
                              // The tv has been marked for deletion
                              // because it is empty.
                              // Undo that...
                              unset( $tmplvars[ $tvName ] );
                              // Set it's value to an empty string for the moment...
                              $tmplvars[ $tvIdentifier ] = array(
                                $tvIdentifier
                                , ''
                              );
                            }
                          }
                          // If the tv is empty...
                          if ( $tmplvars[ $tvIdentifier ][1] == '' )
                          {
                            // Use the default language placeholder...
                            $tmplvars[ $tvIdentifier ][1]
                              = '((yams_data:' . $docId. ':' . $field . '_' . $defaultLangId . '))';
                          }
                          
                        }
                      }
                      break;
                    }
                  break;
                }
                


                This should, I think, set the value of an empty non-default language field to [tt]((yams_data:docId:field_defaultLangId))[/tt].

                For this to work you’ll need to reset the default value of your tvs to blank. You may need to delete existing tv values and resave the document for the plugin to work.

                EDIT: Please let me know if this works. If so, then I think that there are quite a few other people who might be interested in this plugin or variants of it.
                  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.
                  • 14404
                  • 84 Posts
                  Seems like it doesn’t work..

                  What i’v done:

                  1. Created the new plugin with OnBeforeDocFormSave
                  2. Deleted the default value’s from the tv’s: content_nl , content_de , content_fr
                  3. Deleted the content fields of a document
                  4. Saved the document
                  5. Looked for the result

                  Result: Empty content
                    • 22851
                    • 805 Posts
                    Oops, please can you replace..

                        require_once( dirname( __FILE__ ) . '/class/yams.class.inc.php' );
                        require_once( dirname( __FILE__ ) . '/yams.module.funcs.inc.php' );
                    


                    with

                        require_once( $modx->config['base_path'] . 'assets/modules/yams/class/yams.class.inc.php' );
                        require_once( $modx->config['base_path'] . 'assets/modules/yams/yams.module.funcs.inc.php' );
                    


                    and try again?
                      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.
                      • 14404
                      • 84 Posts
                      Still doesn’t work, doesn’t show anything