Active
Project:
BlueMasters
Version:
7.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
14 Jul 2011 at 15:57 UTC
Updated:
21 Feb 2012 at 23:24 UTC
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
Comment #1
pardalman commentedNOTE: The code above removes the second and fith menu link when language=en and first and fourth when language=ja
Comment #2
adelik commentedi 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!
Comment #3
mikec.pt commentedSubscribing...
I have the exact same problem!
Comment #4
mikec.pt commentedI've found a solution... with minor changes to the code!
This is how my "navigation section" looks now!
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
Comment #5
gynekolog commentedworks, but not for tree menu
Comment #6
gtsopour commentedThank you sincerely for your help and for your comments in this issue.
Could you please review the following code?
Thanks
/George
Comment #7
desvers commentedHi,
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.