ThemeShaper Forums » Thematic

[closed]

Drop Down Menus

(11 posts)
  • Started 4 years ago by theBlogButler
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. theBlogButler
    Member

    Hi ya'll, having some problems here with a drop-down menu. First off, I'm using the WP 3.0 menu system. Here is my code for that - note I'm trying to explicitly tell the wp_nav_menu function that I want 2 levels but that didn't make a difference:

    if ( function_exists( 'add_theme_support' ) ) {
    	// This theme uses wp_nav_menu()
    	register_nav_menu( 'bb-menu',_('Client Navigation') );
    }
    function childtheme_menu() { ?>
    	<div id="access">
      		<div class="skip-link"><a href="#content">">
    		<?php _e('Skip to content', 'thematic'); ?></a></div>
      			<?php wp_nav_menu( 'sort_column=menu_order&container_class=menu&menu_class=sf-menu&depth=2' ); ?>
    		</div>
    		<!-- #access -->
    	<?php }
    add_action('thematic_belowheader','childtheme_menu',9);

    And I've set the code in Superfish.css to

    .sf-menu li { 				/* TOP LEVEL MENU */
    	background:		#FFF;
    	list-style:		none;
    }
    .sf-menu li li {			/* SECOND LEVEL MENU (CHILD) */
    	background:		#FFF;
    	list-style: 	none;
    }

    I'm sure I'm missing something here but not sure what or where so I'm asking for ya'lls help.

    Thank you!

    Posted 4 years ago #
  2. theBlogButler
    Member

    Any ideas here?

    Thanks!

    Posted 4 years ago #
  3. what kind of output are you getting instead?

    also- in a recent post, Chris advised us to not use add_theme_support.. which has since been removed from the latest stable version and so your if condition might not be getting triggered depending on how recent your thematic is.

    that post is:
    http://forums.themeshaper.com/topic/add_theme_supportmenus

    and Squidz's reply includes code that could be adapted for you if you only need the 1 menu

    function menu_args( $args ) {
    $args = array( 'menu_class' => 'sf-menu',
    				'sort_column' => 'menu_order',
    				'container_class' => 'menu',
    				'menu_class' => 'sf-menu',
    				'depth' => 2,
    	);
    return $args;
    }
    add_filter( 'thematic_nav_menu_args', 'menu_args' );
    
    function child_access_menu() {
    $menu_sys = 'wp_nav_menu';
    return $menu_sys;
    }
    add_filter('thematic_menu_type', 'child_access_menu');
    Posted 4 years ago #
  4. theBlogButler
    Member

    Thanks Helga. I'm on SVN 715 (i think). You are right, part of my problem is I know not to use add_theme_support but not sure what syntax to use in it's place. :(

    So I just took out the conditional statement and brute force am adding the register_nav_menu:

    // This theme uses wp_nav_menu()
    register_nav_menu( 'bb-menu',_('Client Navigation') );

    I am getting the output in my HTML but I think that my problem is in my superfish.css as it is not displaying when I hover over it.

    I can see the sub-menu in my generated html and hidden:

    display: none; visibility: hidden;

    Then it switches to visible in the html when I hover:

    display: block; visibility: visible;

    So it is showing just not where I can see it.

    Posted 4 years ago #
  5. check the code i added in the edit above. we probably posted at the same time.

    i don't yet know what to use in it's place. perhaps if_function_exists ('register_nav_menu') or if_function_exists('wp_nav_menu') ??

    if you are not releasing the theme publicly then you probably don't need to worry about it. the if_function_exists call is to make sure old versions of WP don't choke and cough up white screens of death. but if you know you are working w/ WP3 then you know you are ok.

    edited to add: that i just tried my code w/ the thematic 0.9.6.2 (or whatever is currently in the repo) and it does not work (expected) but it doesn't break either as it simply falls back to wp_list_pages. if you need there to be a menu even if one isn't created you can add a fallback parameter to your arguments array:

    function menu_args( $args ) {
    $args = array( 'menu_class' => 'sf-menu',
    				'sort_column' => 'menu_order',
    				'container_class' => 'menu',
    				'menu_class' => 'sf-menu',
    				'fallback_cb' => 'mytheme_nav_fallback',
    				'depth' => 2,
    	);
    return $args;
    }
    add_filter( 'thematic_nav_menu_args', 'menu_args' );
    
    function child_access_menu() {
    $menu_sys = 'wp_nav_menu';
    return $menu_sys;
    }
    add_filter('thematic_menu_type', 'child_access_menu');
    
    //fall back to regular wp_page_menu if no menu is selected
    function mytheme_nav_fallback() {
        $args = array(
    		'show_home' => 'Home',
    		'sort_column' => 'menu_order',
    		'menu_class' => 'menu',
    		'echo' => true
        );
    Posted 4 years ago #
  6. theBlogButler
    Member

    So one thing I just noticed - it enables the sub-menu but NOT any of the sub-menu ITEMS. Which would be why they don't display.

    I'll admit I'm in over my head here :(

    Posted 4 years ago #
  7. theBlogButler
    Member

    Thanks Helga. This is for a single client, so I'm working out this one last kink on their custom theme...

    Posted 4 years ago #
  8. 'So one thing I just noticed - it enables the sub-menu but NOT any of the sub-menu ITEMS. Which would be why they don't display.'

    i dont understand what you mean here. you've set the depth to 2, so you have intentionally limited the menu to only show

    • Top Level 1
      • Sub Level 1
      • Sub Level 1
    • Top Level 1

    even if your wordpress menu has a 2nd sublevel

    • Top Level 1
      • Sub Level 1
        • Sub Level 2
        • Sub Level 2
      • Sub Level 1
    • Top Level 1
    Posted 4 years ago #
  9. theBlogButler
    Member

    Right I only want to see 2 levels. I can see the main level, then I see the html code below it (Sub Level 1) and that level gets activated whenver I hover over *any* of the Top Level nav items, but they never pop out and display.

    Posted 4 years ago #
  10. theBlogButler
    Member

    Ok this is definately a problem with my superfish css code - I dropped Ian's default code in there and it works fine. So I'll reset with my superfish code.

    Thank you Helga for the assistance and guidance!

    Posted 4 years ago #
  11. yeah it is much easier to start from the thematic default and tinker off of something that is working than it is to try to pull everything from thin air.

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.