We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22295
    • 153 Posts
    When using YAMS and managermanager, normally, the "internal name" (pagetitle) is the same as the language specific title (at least for english if not more..)

    here’s a simple managermanager widget to do that automatically (enough with the copy&paste..)

    a. create the synctitle folder: \assets\plugins\managermanager\widgets\synctitle
    b. put the attached synctitle.php
    c. in your mm_rules chunk, add this line at the end: mm_widget_synctitle(’en,ko’);
    (or whatever languages you want the internal name to be synced to, comma separated)

    It will sync on initial entry, and then later, if needed - there’s the ’force sync’ link.

    good luck



    synctitle.php
    <?php
    
    //---------------------------------------------------------------------------------
    // mm_widget_synctitle
    // Auto sync Internal Name (pagetitle) to other languages
    //--------------------------------------------------------------------------------- 
    
    
    function mm_widget_synctitle($langs='', $roles='', $templates='') {
    	
    	global $modx, $content, $mm_fields;
    	$e = &$modx->Event;
    	
    	if (useThisRule($roles, $templates)) {
    		
    		$output = '';	
    
    		if (isset($content['template'])) {
    			$page_template = $content['template'];
    		} else {
    			$page_template = $modx->config['default_template']; 
    		}
    
    		$langs = makeArray($langs);
    		if (empty($langs)) return;
    		$tvIds = array();
    		foreach ($langs AS $lang) {
    			$tvIds[] = '#' . $mm_fields['pagetitle_'.$lang]['fieldname'];
    		}
    
    
    		
    		$output .= "// ---------------- mm_widget_synctitle ------------- \n";
    		$output .= '
    			$j("input[name=pagetitle]").blur(function(){
    				var newVal = $j(this).val();
    				$j("'.implode( "," , $tvIds ).'").each(function(){
    					if ($j(this).val() == "") {$j(this).val(newVal);}
    				});
    			});
    
    			$j("input[name=pagetitle]").parent().append("<a href=\"#\">(sync titles)</a>").click(function(){
    				var newVal = $j("input[name=pagetitle]").val();
    				$j("'.implode( "," , $tvIds ).'").val(newVal);
    				return false;
    			});
    			
    		';
    	}
    	$e->output($output . "\n");
    } 
    ?>

      • 22851
      • 805 Posts
      PaulSuckling Reply #2, 14 years ago
      Hi oori

      First of all, thank you very much for sharing your managermanager widget. I didn’t even know that it was possible to extend managermanager with custom functions in that way and I like it a lot.

      One thing you might not be aware of is that I have already built in to YAMS an option to synchronise the default language pagetitle with the "internal name" when a document is saved. Please see: Modules>YAMS>"Other Params">"Document Layout Settings">"Autoupdate Manager Document Title"

      I think this works in the opposite direction to your managermanager widget. The "internal name" is copied from the default language pagetitle, rather than the "internal name" being copied to any of the multilingual pagetitles.
        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.
        • 22295
        • 153 Posts
        I think this works in the opposite direction to your managermanager widget. The "internal name" is copied from the default language pagetitle, rather than the "internal name" being copied to any of the multilingual pagetitles.

        For the end-user (at least for my client..) the flow from "internal name" to page-titles make more sense (it’s the first field in sight), especially as their default language is not english (and has no english chars (korean) for auto-alias creation..) the other nice thing is that with client-side sync it’s directly there, and not only after save, so they don’t need to "know the logic", it’s simply there, and they can modify if needed.
        Thanks for your YAMS, btw..
          • 22851
          • 805 Posts
          PaulSuckling Reply #4, 14 years ago
          I understand what you’re saying. Sounds like the widget you created does exactly what you need. Thanks once again 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.