• Resolved johnrork

    (@johnrork)


    I’m planning on using dynamic menus for navigation across a primary blogs and sub-blogs with the same theme; however, menus are confined to the blog in which they are created.

    Is there a way to pull a primary blog’s menus into a sub-blog?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    No. They’re like widgets – Confined to their own blog.

    Thread Starter johnrork

    (@johnrork)

    Can’t there be a way to do this programmatically in the theme? To temporarily step out of the current blog and load a menu as if it were a different blog, then back again?

    Something like WPMU’s switch_to_blog() function?

    I realize that the menu wouldn’t appear in admin… that’s actually the desired effect: all of the functionality, none of the control ??

    Obviously, this would require sub-sites to use a child theme; that is no problem.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    You can put that in as a feature request, but right now there isn’t. Though that said, if you’re having subsites use a child theme anyway, you may be better off doing this via a functions.php file in the parent, have THAT control the menu.

    I keep thinking about how you’d do this, to handle both MultiSite and Stand Alone, and I come up with a lot of contradicting answers! On one hand, it’s a perfect example of how MU should have master level administration, but on the other, if I was running multiple domains off one site, I wouldn’t want this at all. Argh.

    Thread Starter johnrork

    (@johnrork)

    To me, it seems that menus—which are likely to contain navigation—should be handled in the same way as plugins, which have an “activate” and “network activate” options.

    you may be better off doing this via a functions.php file in the parent, have THAT control the menu.

    Care to elaborate on that? I mean, I am currently using widget areas and navigation menu widgets. The widget area is declared in the functions.php file, but the corresponding widgets are only available to the blog in which they were created.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    To me, it seems that menus—which are likely to contain navigation—should be handled in the same way as plugins, which have an “activate” and “network activate” options.

    Except that not everyone uses MultiSite. And not everyone uses MultiSite that way. I agree, some of us want multiple blogs, all with the same (or VERY similar) layouts and, in that case, it’s a mother to get all your widgets the same on all blogs. In other cases, for example, I run a MultiSite where each and every blog has it’s own design (one garish, one simple, one bog standard, etc). And then there are people who have multiple DOMAINS, and there shouldn’t be standard navs for all of them.

    As a sidebar – “network activate” just means ‘This plugin is turned on for all blogs.’ The settings for each blog STILL need to be customized per blog. So … there’s that.

    Anyway, my idea about the functions.php is a little unspecific, since it’s theory right now. If you defined your nav menu as a function (li and ul and all via echo) and then called it as an add-action to the widget area, it SHOULD put the code in. Then it’s just a matter of CSS styling. This is all entirely untested, but in THEORY it’s how a lot of parent themes work, so I’m pretty sure it can be done. I’m just not 100% crystal on HOW :/

    this sort of thing is definitely plugin territory,. Not every wants or needs it, and done wrong, it can be a real drain on system resources.

    Like this is how we do it in MU:

    just before the nav bar code in your theme’s header.php put
    <?php switch_to_blog(1); ?>
    right after the navbar code put
    <?php restore_current_blog(); ?>
    then it will always show the pages from Blog #1.

    But switch_to_blog can get expensive when you have a lot of blogs and I am not sure if this function has the same name in 3.0. Might as well try.

    Thread Starter johnrork

    (@johnrork)

    Sorry, I guess I a follow-up is in order!

    switch_to_blog() is indeed alive and well in 3.0.

    It did not do exactly what I wanted, as I planned to use menus in widget mode for ease of administration, and you can’t load a widget area via switch_to_blog().

    However, loading them via wp_nav_menu() did work, and only cost the ability to easily change menu order. All in all, it was a good compromise.

    Thanks for the help!

    johnrork – I am trying to do this exact thing and I was wondering if you could possibly give a little insight as to how you accomplished this using wp_nav_menu()?

    worked awesome… thanks Andrea_r and johnrork.

    my code in my custom header:

    <?php switch_to_blog(1); ?>
    <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'menu-name' ) ); ?>
    <?php restore_current_blog(); ?>

    my code in functions.php

    <?php
    add_theme_support( 'menus' );
    	register_nav_menus( array(
    		'menu-name'' => __( 'Menu Full Name', 'my_theme_name' ),
    	) );
    ?>

    Max

    (@brokelikemax)

    Question – could you wrap your whole header in:

    <?php switch_to_blog(1); ?>
    -- my header code here --
    <?php restore_current_blog(); ?>

    to have the whole header area the same as the first blog?

    Max

    (@brokelikemax)

    @jtsternberg thanks for posting your results.

    While I understand the code in the header, what is the code in functions.php for?

    ha, i don’t know why i put that, but i ended up deleting it. It’s not needed. oops.

    Andrea – thanks for posting the <?php switch_to_blog(1); ?> it took me forever to find this thread but it was exactly what I was looking for. I hope WP adds a “global nav” feature for network sites, but this switch worked wonders.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Using 3.0b1 menus for multisite navigation’ is closed to new replies.