How-To set Custom Menu's collapsed as default
-
I’ve searched and searched can not seem to find the answer for this. Is it possible to
- Specifiy that certain custom menu’s are to be collapsed as the default?
- And conversely can other custom menu’s be set to expand as the default?
I’d appreciate the answer and the code if I need it to make this happen please and thank you in advance.
-
Can you paste here code of your sidebar.php from your theme.
Yes indeed, here it is … from sidebar.php in Mandigo v. 1.42
<?php // this file defines the default sidebar // if you are using widgets, you do not need to edit this file global $mandigo_options; // heading level for widget title (h1, h2, div, ...) $tag_widget = $mandigo_options['heading_level_widget_title']; ?> <td id="sidebar1"> <ul class="sidebars"> <?php // if wp doesn't support sidebars, or if we are not using any widget in sidebar 1 if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar 1')) { // our search widget, defined in functions.php widget_mandigo_search(); // our calendar widget, defined in functions.php widget_mandigo_calendar(); // if we are browsing a category archive if (is_category()) { $what_youre_doing = sprintf( __('You are currently browsing the archives for the \'%s\' category.', 'mandigo'), single_cat_title('', false) ); } // if wp supports tags and this is a tag archive elseif (function_exists(is_tag) && is_tag()) { $what_youre_doing = sprintf( __('You are currently browsing the %s weblog archives for posts tagged \'%s\'.', 'mandigo'), sprintf( '<a href="%s/">%s</a>', get_bloginfo('home'), get_bloginfo('name') ), single_tag_title('', false) ); } // if this is a daily archive elseif (is_day()) { $what_youre_doing = sprintf( __('You are currently browsing the %s weblog archives for the day %s.', 'mandigo'), sprintf( '<a href="%s/">%s</a>', get_bloginfo('home'), get_bloginfo('name') ), get_the_time(__('l, F jS, Y', 'mandigo')) ); } // if this is a monthly archive elseif (is_month()) { $what_youre_doing = sprintf( __('You are currently browsing the %s weblog archives for %s.', 'mandigo'), sprintf( '<a href="%s/">%s</a>', get_bloginfo('home'), get_bloginfo('name') ), get_the_time(__('F, Y', 'mandigo')) ); } // if this is a yearly archive elseif (is_year()) { $what_youre_doing = sprintf( __('You are currently browsing the %s weblog archives for the year %s.', 'mandigo'), sprintf( '<a href="%s/">%s</a>', get_bloginfo('home'), get_bloginfo('name') ), get_the_time('Y') ); } // if this is a search result elseif (is_search()) { $what_youre_doing = sprintf( __('You have searched the %s weblog archives for %s. If you are unable to find anything in these search results, you can try one of these links.', 'mandigo'), sprintf( '<a href="%s/">%s</a>', get_bloginfo('home'), get_bloginfo('name') ), '<strong>\''. wp_specialchars($s) .'\'</strong>' ); } // otherwise, not sure when this is triggered elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { $what_youre_doing = sprintf( __('You are currently browsing the %s weblog archives.', 'mandigo'), sprintf( '<a href="%s/">%s</a>', get_bloginfo('home'), get_bloginfo('name') ) ); } // make sure the variable has been set if ($what_youre_doing) { ?> <li><?php echo $what_youre_doing; ?></li> <?php } // the list of pages wp_list_pages( array( 'sort_column' => 'menu_order', 'title_li' => sprintf( '<%s class="widgettitle">%s</%s>', $tag_widget, str_replace('&', '%26', __('Pages', 'mandigo')), $tag_widget ), ) ); ?> <li><<?php echo $tag_widget; ?> class="widgettitle"><?php _e('Categories', 'mandigo'); ?></<?php echo $tag_widget; ?>> <ul> <?php // the list of categories wp_list_cats( array( 'sort_column' => 'name', 'optioncount' => 1, 'hide_empty' => 0, 'hierarchical' => 1, ) ); ?> </ul> </li> <?php // if wordpress supports tags if (function_exists('wp_tag_cloud')) { ?> <li><<?php echo $tag_widget; ?> class="widgettitle"><?php _e('Tags', 'mandigo'); ?></<?php echo $tag_widget; ?>> <?php wp_tag_cloud(); ?> </li> <?php } // if this is the frontpage if (is_home() || is_page()) { // put the blogroll get_links_list(); } // our meta widget, defined in functions.php widget_mandigo_meta(); } ?> </ul> </td>
That option can be created but it will take some time.
For now you can tell me which menus you want to keep collapsed i’ll tell you that exact code.
Ok great. All of them would be the short answer. In the Demo site I gave in my opening message this would be:
- Search
- About Us
- Worship Services
- News and Events
- Links
- We are members of
- Services
- Map & Directions
And that if any thing else is added it too by default would be collapsed. Personally I think this is an option that should be included with the “Custom Menu” feature in 3.1 .
Thank you
One of our guys came up with a quick and dirt way of doing this. In the footer.php file we inserted
// induce a click to force the widgets to be displayed collapsed jQuery(".widgettitle div").hide(); jQuery(".widgettitle, .linkcat *:first, .wpg2blockwidget h3").trigger("click"); }); // ]]> --> </script> <?php // HTML Inserts: very end of the page echo get_option('mandigo_inserts_veryend'); ?>
This is slow but for now, for demonstration purposes it works.
- The topic ‘How-To set Custom Menu's collapsed as default’ is closed to new replies.