Using
D7.2
Internationalization i18n 7.x-1.0-rc1
PHP 5.2.9

So far I've managed to solve it by removing the menu entries directly (depending on the order the appear):

I've inserted here (in both files: page--front.tpl.php and page.tpl.php):

<!--navigation-->
        <div id="navigation">
<?php $menu_name = variable_get('menu_main_links_source', 'main-menu');           
            $main_menu_tree = menu_tree($menu_name);                    
            print drupal_render($main_menu_tree); ?>
        </div><!--EOF:navigation-->

the following code:


//Read of the current language of the user at the beginning of the file
global $language;
$idiomaActual= $language->language;
$menu_name = variable_get('menu_main_links_source', 'main-menu');
            echo 'menu_name:'.$menu_name.'<br>';
            $main_menu_tree = menu_tree($menu_name);
           
            $leaffs = -1;
            $contentLeaffs = -1;
            foreach($main_menu_tree as $leaff => $value)
            {
                $leaffs++;
                if($idiomaActual == 'en')
                {
                   
                    if(($leaffs == 1)||($leaffs == 4))
                    {
                        //echo 'DELETING NODE.<br>';
                        unset($main_menu_tree[$leaff]);   
                    }                               
                }
                else
                {                                       
                    if(($leaffs == 0)||($leaffs == 3))
                    {
                        //echo 'DELETING NODE.<br>';
                        unset($main_menu_tree[$leaff]);   
                    }               
                }
               
            }                       
            print drupal_render($main_menu_tree);

Solving this would save some cpu cicles and some of my nerves when editting the file every time I change the order of my menu links

Just in case it helps there is a similar issue (already solved) with another theme (Fusion) in: http://drupal.org/node/1127162

P.S.: I do know this code could be much more optimal but so far it works

Comments

pardalman’s picture

NOTE: The code above removes the second and fith menu link when language=en and first and fourth when language=ja

adelik’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Priority: Normal » Critical

i have this same problem with 7.x-1.x-dev. I tried the solution above and it did not work. Main menu still showing double (in both languages). I've tried swapping theme to Bartik 7.8 which come with the core and it worked just fine, displaying only one menu in selected language. please help!

mikec.pt’s picture

Subscribing...

I have the exact same problem!

mikec.pt’s picture

I've found a solution... with minor changes to the code!

This is how my "navigation section" looks now!

<div id="navigation">
            <!--<?php $menu_name = variable_get('menu_main_links_source', 'main-menu');
            $main_menu_tree = menu_tree($menu_name);
            print drupal_render($main_menu_tree);?>	-->
	<?php print theme('links__system_main_menu', array(
							'links' => $main_menu,
							'attributes' => array('class' => 'menu')
							)); ?>					
</div><!--EOF:navigation-->

I found the solution by reading about: How to print a menu in Drupal 7?

I left the old code comment, not only for reference, but also because it helped me find out what/where class I should use, because if we keep the id and classes from the example on how to print a menu, it will obviously look ugly, I also removed the Heading setting form the same reason!

The id and class tag's are applied to the "ul" and in this theme we only use class="menu"

I think you get the point...

So, just change the page--front.tpl.php and page.tpl.php navigation section!

Hope this helps!

Mike

gynekolog’s picture

works, but not for tree menu

gtsopour’s picture

Assigned: Unassigned » gtsopour
Issue tags: +Bluemasters theme, +bluemasters

Thank you sincerely for your help and for your comments in this issue.
Could you please review the following code?

Thanks
/George

desvers’s picture

Thank you sincerely for your help and for your comments in this issue.
Could you please review the following code?


    if (module_exists('i18n')) {
    $main_menu_tree = i18n_menu_translated_tree(variable_get('menu_main_links_source', 'main-menu'));
    } else {
    $main_menu_tree = menu_tree(variable_get('menu_main_links_source', 'main-menu')); 
    }
    print drupal_render($main_menu_tree);
    

Thanks
/George

Hi,

Thanks for your help.

This modification works for 'page--front.tpl.php' but not for 'page.tpl.php' (in div 'navigation' ) in which there is no main menu anymore when i apply this change in code.