Skip to:
Content
Pages
Categories
Search
Top
Bottom

Getting a consistent look

  • @anonymized-96400

    Inactive

    Hey there,

    I have installed BP & WPMU now for a couple days and thought I’d share a few points I had trouble with. All of them have to do with getting the same look throughout your site.

    First of all, I copied header.php into my child theme and changed the links in the main menu. The main menu makes use of this bit quite a lot: echo get_option('home').

    I changed this to echo SV_HOME_LINK and added this line to my themes functions.php:

    if( ! defined('SV_HOME_LINK') ) define( 'SV_HOME_LINK' , 'http://sv.localhost' );

    This does two things. It makes sure that the links in the menu always point to the same location, which they would not have from another blog except the main and I only have to change the value of SV_HOME_LINK once (in functions.php) instead of a few times in the header.php file when I move everything to a production server.

    The next thing I wanted was a prominent logout link in the admin bar.

    function sv_add_adminbar()
    {
    if ( is_user_logged_in() )
    {
    echo '<li id="logout-bar" class="no-arrow">';
    bp_log_out_link();
    echo '</li>';
    }
    }
    add_action( 'bp_adminbar_menus', 'sv_add_adminbar', 14 );

    Put the above function into your functions.php file and it’s sorted.

    I also wanted every new blog to use the same default theme from the start and I don’t want to call that theme ‘default’, cause it gets overwritten when you update WPMU. This little function (placed in bp-custom.php) takes care of that (you have to replace sv with the name of your stylesheet):

    function sv_change_template( $blog_id )
    {
    switch_to_blog( $blog_id );
    update_option('template', 'bp-sn-parent');
    update_option('stylesheet', 'sv');
    restore_current_blog();
    }
    add_action( 'wpmu_new_blog', 'sv_change_template' );

    All seemed to be well. I installed a test user with a test blog and his blog posts showed up, but his index file was empty, so I had a look at home.php. This is the code I had in that file after fiddling with it before already:

    get_header();
    if( is_user_logged_in() ) {

    //here I have a widget area and a sidebar shown only to logged in users

    } else {

    // here's the code for logged out users, like random members, login form
    // and the latest post from the main blog

    }
    get_footer();

    I needed the homepage of every blog to show an index of their posts, so I changed the above code to this:

    get_header();
    // only do the following for the site homepage
    if( is_main_blog() ) {
    if( is_user_logged_in() ) {

    //here I have a widget area and a sidebar shown only to logged in users

    } else {

    // here's the code for logged out users, like random members, login form
    // and the latest post from the main blog

    }
    // and this bit for every other blog
    } else {

    // here I put the normal loop from index.php plus the sidebar

    }
    get_footer();

    That was basically it. I did some more stuff, but that was all specific to the site I’m setting up. Never having looked at BP or WPMU before it took me the better part of two days to figure out the above things, so I thought I share them to make it easier for others.

    Enjoy!

    Boris

Viewing 8 replies - 1 through 8 (of 8 total)
  • @anonymized-96400

    Inactive

    I have just discovered the global variable $bp :) Using that we can skip the SV_HOME_LINK parts above and do it with a function, that we put in bp-suctom.php:

    function sv_get_homelink()
    {
    global $bp;
    return $bp->root_domain;
    }

    Now we can use

    echo sv_get_homelink()

    instead of

    echo get_option('home')

    in header.php.

    @toregus

    Participant

    Great! It’s encouraging to read about others making 1.1 work for them.

    @mariusooms

    Participant

    Another approach would be, in your header, wrap the main menu links with this code:

    switch_to_blog( 1 )
    ...your main menu links...
    restore_current_blog();

    Also check out this plugin, http://wpmudev.org/project/New-Blog-Defaults, it has a bunch of handy options for new blogs. Including setting a default blog theme.

    In BP there are more ways to skin a cat :) Thanks for sharing your solutions.

    @anonymized-96400

    Inactive

    Ok, that’s pretty clever. Easier than my solution :) I prefer not to install a plugin if I don’t have to, but I’ll check the plugin out.

    @bpisimone

    Participant

    Btw. how would I proceed if I wanted to add an item to bp_adminbar_account_menu? Obviously not a logout link because there is one already, but I was not able to figure it out up until now.

    @anonymized-96400

    Inactive

    You can’t hook into the function responsible for the account menu at the moment, so it’s not possible right now using an action You’d have to hack core files, so it’s not a good solution. It seems the only menu you can hook into is ‘visit’.

    @bpisimone

    Participant

    Pitty, thanks for the explanation anyways!

    @toregus

    Participant

    It seems the only menu you can hook into is ‘visit’.

    You can alter navbar, userbar and optionsbar. It’s not the same but still useful. I’ve done it but I don’t remember how to alter the optionsbar anymore.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Getting a consistent look’ is closed to new replies.
Skip to toolbar