We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1570
    • 38 Posts
    I have this snippet as an example:
    <?php
    $pageid = $modx->documentObject['id'];
    $table = "ch_site_content";
    $tableVars = "ch_site_tmplvar_contentvalues";
    
    echo'<div id="navigation">
        <ul>
    	';
    
    $sql = "Select * from $table where parent = 0 and published = 1 and deleted != 1 and hidemenu = 0 order by menuindex asc";
    $result = $modx->db->query($sql); 
    while($row = $modx->db->getRow( $result ) )
    {
    	if($row['id'] == $pageid)
    		echo'<li class="navigationselected"><a href="[~'.$row['id'].'~]">'.$row['pagetitle'].'</a></li>';
    	else
    		echo'<li><a href="[~'.$row['id'].'~]">'.$row['pagetitle'].'</a></li>';
    }
        echo'</ul>
    </div>
    ';
    ?>


    Notice where there is $row[’pagetitle’], how can i make it output the pagetitle of the language the user in the site is currently viewing and not the pagetitle of the default doc?
      • 22851
      • 805 Posts
      You could add an extra parameter to your snippet, [tt]&langid=`(yams_id)`[/tt]. This will pass it the id of the current language. Then the names of the multilingual template variables you will need to access will be given by, for example, [tt]’pagetitle_’ . $langid[/tt].
        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.