I have the module installed and configured with blocks set to 0 intending to skip the block code overhead and use theme functions. I had primary_links working with the following code:
<div id="nice-primary" class="clear-block">
<?php print theme_nice_menu_primary_links('down', NULL); ?>
</div> <!-- /#primary -->
But when I tried to add the navigation menu:
<div id="nice-primary" class="clear-block">
<?php print theme_nice_menu_primary_links('down', NULL); ?>
<div id="nice-navigation" >
<?php print theme('nice_menu', 0, 'navigation', NULL, 'down'); ?>
</div> <!-- /#navigation -->
</div> <!-- /#primary -->
I get the word Array will the navigation menu should be. See nice_menu_output.png attached
The problem is clearly with the theme() function usage as
<?php print theme('nice_menu', 0, 'primary_links', NULL, 'down'); ?>
results in Array as well as shown in nice_menu_output_2.png
Comments
Comment #1
fathershawnTrying to attach the screen shot graphics files again as I don't see them here.
Comment #2
fathershawnI went to look at the code in the module for the theme_nice_menu function. If both conditions for $menu_tree fail nothing gets assigned to $output. So I setup the following debug code at line 360 before the If statements:
Which resulted in:
menu_tree is null
Array
So now to figure out why $menu_tree is empty....
Comment #3
fathershawnWell, I've changed this to a bug report and apologize in advance if what looks like a bug is merely a limitation in my growing php knowledge.
$menu_tree is not declared anywhere in the module, nor a search through my drupal install find it anywhere in core, so it doesn't look like it's included from somewhere else. Is there some code missing?
Comment #4
fathershawnOK, so I missed the obvious...
Is supposed assign the results of the theme function to $menu_tree and skip the block if the function returns NULL.
So I need to track down why the function returns NULL.
So, I adapted the primary links theme function as follows:
Which output a Nice Menu of the Navigation menu when called as theme_nice_menu_other_links(0, 'navigation', NULL, 'down'). So there must be something about the menu_name being passed to theme_nice_menu in the original which is causing theme_nice_menu_tree to choke.
Comment #5
fathershawnThe theme_nice_menu function works fine when called by theme_nice_menu_primary_links so its not a bug.
Comment #6
fathershawnOK. I'm back to being stumped. I added some debug code to theme_nice_menu to try to understand why it works in some situations and not others. The debug version of the function looks like:
So theme_nice_menu_primary_links calls theme_nice_menu and the following is dumped in the file:
When the following code is executed in page.tpl.php to call the function shown above
the file dump is:
And a proper Nice Menu of the navigation menu is generated.
When the standard function call is executed in page.tpl.php:
the file dump is:
and the result is the word Array instead of the menu.
Both sets of parameters look the same to me and so I can't figure out why it doesn't work when called directly. In the meantime, I've worked around the problem by adding a custom function to my template.php:
Comment #7
Standart commentedPossibly your problem occurs because you don't output the right part of what the theme function returns. As in http://drupal.org/node/236418 which is linked from the project page you have to output
$menu['content']like so:This is the intended usage.
Comment #8
Standart commentedPlease re-open if this doesn't fix your problem.
Comment #10
fathershawnThank you so much for the tutorial! Changed my page.tpl.php code to:
And it works exactly as I expected! So I was able to remove the custom theme function and simplify the setup! This ethos of helping one another is what's great about the Drupal community!