The MU forums have moved to WordPress.org

"Global" Sidebar (15 posts)

  1. jody001
    Member
    Posted 14 years ago #

    Building a WPMU site with BuddyPress....

    Right now trying to figure out how to add a "global" sidebar to the MU blogs. MU Blogs have their own sidebars and control panel. This is great.

    What I want is to add a second sidebar, one that will appear on all MU sites. This sidebar, call it "global sidebar" as opposed to a users "local sidebar," has its widgets controlled at the admin level.

    How would I code this? Still learning PHP, but I'm getting thrown as MU Blogs have their own functions file that define their sidebars. How do I get the local, MU blogs to see the global sidebar, since it is defined through a different file?

  2. andrea_r
    Moderator
    Posted 14 years ago #

    "Blogs have their own functions file that define their sidebars."

    No, that just defines the widgetized areas.

    If you want a secodn sidebar on all blogs, you'll have to add it to the themes.

    The process for making this controlled from and by the site admin, is a lot more difficult.

    It's do-able though. Just not what I'd call a beginner step.

  3. jody001
    Member
    Posted 14 years ago #

    Ugh.

    Where would you suggest I look to read up to figure out how to do this?

  4. andrea_r
    Moderator
    Posted 14 years ago #

    Do you really needs widget for the admin control, or is the info going to be relatively static? (for the global sidebar)

  5. andrea_r
    Moderator
    Posted 14 years ago #

    also some tips in this thread:
    http://mu.wordpress.org/forums/topic/12435

  6. jody001
    Member
    Posted 14 years ago #

    Andrea, no, I don't really need it. I've been trying to remake C# site over into a Wordpress and that was one of two issues that's still confounding me.

    It's mostly for advertising. I can hard code the ad code into the theme, since the users won't have access to theme mods, just widgets.

    I've got one more issue that I'll probably post about here too, if I can't figure it out in the next day or so.

  7. andrea_r
    Moderator
    Posted 14 years ago #

    I was going to suggest hardcoding it in. It's fast & easy. Keep it outside the widget area, and you're good.

  8. landykos
    Member
    Posted 14 years ago #

    I have been trying to figure this out myself. I would really love to get his working..

    @andrea_r

    It's do-able though. Just not what I'd call a beginner step.

    You say this is do-able, can you point me in the right direction as to how to do this.

    I have posted the same topic here.

    I am not a beginner at all and would love to jump in on this.

    Thanks,
    LK

  9. andrea_r
    Moderator
    Posted 14 years ago #

    Well, do-able as in we've done it before, but it's not written down anywhere.

    One way, if all blogs use the same theme, is to do a switch_to_blog, then pull in the main blog's sidebar.

  10. landykos
    Member
    Posted 14 years ago #

    I did that and it worked but for some reason not all the widgets would work. Is that the only work around you have tired?

    Thanks,
    LK

  11. jody001
    Member
    Posted 14 years ago #

    Landy, thanks for that. I'm so new I didn't know there was a "switch_to_blog" command in WP. Now it's obvious.

    I'm going to give that a shot for the sidebar to see if it works, if for no other reason than to learn how to do it. If not I'll hard code.

    It might also help with my other, unposted-as-yet question, where I want the category nav from blogid=1 to appear at the top of whatever blogid=x happens to be.

  12. plug_n_author
    Member
    Posted 14 years ago #

    WPMU itself uses switch_to_blog() quite a bit in the backend. It does a switch_to_blog($blog_id), does something with the blog (standard WP functions), and then does a restore_current_blog() to revert back to the current blog. Look in WPMU source for examples, but you should already have an idea. That way you don't have to know what blog is currently active and you let WP do the heavy lifting. It also fixes issues - probably the ones 'landykos' is having.

  13. landykos
    Member
    Posted 14 years ago #

    Yeah, there is also a global variable $current_blog that can be used in loops if you are trying to pull stuff from all your blogs in one loop.

    $current_blog->blog_id will give you the ID for the current blog.

  14. andrea_r
    Moderator
    Posted 14 years ago #

    It might also help with my other, unposted-as-yet question, where I want the category nav from blogid=1 to appear at the top of whatever blogid=x happens to be.

    If you get the cats all set up in blog 1, and don't plan on changing them afterwards, you can hardcode them right in the template. This will decrease the load and processing a wee bit.

  15. jody001
    Member
    Posted 14 years ago #

    Am I right in understanding that even when you use the switch_to_blog function, if that called blog uses a function file it's still going to look locally for that file and not into called directory?

    In other words I'm in blog 2, ask it to execute something from blog 1, that something originally requires a look in the functions.php file for blog 1 but do to where this is happening looks into blog 2 for the information.

About this Topic