Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

How to: Modify the bp admin bar (19 posts)

Started 3 years, 1 month ago by: Burt Adsit

  • Profile picture of Burt Adsit Burt Adsit said 3 years, 1 month ago:

    http://codex.buddypress.org/developer-docs/modifying-the-buddypress-admin-bar/

    The above is a link to the codex docs for how to alter the admin bar. If you have any questions post them here.

  • Profile picture of Thebigk thebigk said 3 years, 1 month ago:

    *bump*

    I want to add link titled ‘Help’ to the admin bar which will point to the static ‘Help’ pages on my site. How can I do that?

  • Profile picture of Burt Adsit Burt Adsit said 3 years, 1 month ago:

    I have a special fondness for the admin bar. It was the first thing I started modifying in bp.

    You’ve got to create a new function that responds to the action ‘bp_adminbar_menus’. Something like this:

    function my_help_link(){
    	?>
      <li><a href="http://someplace.org">Help</a&gt;
    
    	<ul class="your-ul-list-css-classname">
      <li><a href="http://someplace.org">Help 1</a></li>
      <li class="alt"><a href="http://someplace.org">Help 2</a></li>
      <li><a href="http://someplace.org">Help 3</a></li>
      <li class="alt"><a href="http://someplace.org">Help 4</a></li>
      <li><a href="http://someplace.org">Help 5</a></li>
    	</ul>
    
    	</li>
    	<?php
    }
    add_action( 'bp_adminbar_menus', 'my_help_link', 14 );

    Here with formatting: http://pastie.org/451047

    The call add_action() has a number at the end which is the ‘priority’. When the fn gets triggered in the great scheme of things. If you look at the code for the admin bar in /bp-core/bp-core-adminbar.php, you’ll see a bunch of calls like this at the end of the file. They setup the sequence for the menu items. Lower priority numbers get run first and the corresponding menu item shows up first.

    I gave our little help item a priority of 14 so it shows up at the end of the normal menu item sequence. If you want to slide it in between menu items that have a priority of 4 and 6 then give your help add_action() call a priority of 5.

  • Profile picture of Burt Adsit Burt Adsit said 3 years, 1 month ago:

    Oh ya. the class=”alt” css things are what alternate the colors in the drop down. You can just drop whatever function you do create in bp-custom.php along with the add_action() call and it works pretty slick.

  • Profile picture of Tutsie Tutsie said 3 years, 1 month ago:

    How could I go about adding the bp admin bar to the top of my wordpress back end admin pages?

  • is it possible to have the admin menu start on the buddypress image, rather than my account,
    i plan to rewrite all the menu items when i redesign my site, and i want to attach a menu to the buddypress ‘home’ link

  • Profile picture of Burt Adsit Burt Adsit said 3 years, 1 month ago:

    @Tutsie, upgrade to RC2/trunk. That feature was added some time ago.

    @Hyrxx, you’d have to move the logo into the actual <ul><li> structure of the menu itself. Right now it sits outside of that. It’s not really part of the menu as of now. I just finished doing a tutorial on altering the admin bar as part of this thread: http://buddypress.org/forums/topic.php?id=2283

    Believe it or not I’m getting kinda burned out on the admin bar. I know it’s one of the most visible aspects of bp. It is also one of the easiest ways to allow your users to navigate to important areas of your site. I just don’t have time to tackle that right now. I have a project I’m working on that needs attention.

  • Profile picture of Thebigk thebigk said 3 years, 1 month ago:

    @ Burtadsit: Thanks a ton for all your help. I just got my link up! :D YO!

  • im pretty good with modifying it, i just dont want to modify the actual files, what is the best way to implement a plugin kinda thing to tell bp the actual html to use?

  • Profile picture of TheEasyButton TheEasyButton said 3 years ago:

    Thank you Burt Adsit for that code. Like Hyrxx I was trying to figure out how to change the bar without hacking into the core. Does no good to make a template to share with others if they have to hack the core.

    Hyrxx, to make the change that Burt Adsit explained, I simply pasted his code into the bottom of the functions.php in my theme.

  • Profile picture of dwpers dwpers said 2 years, 5 months ago:

    http://codex.buddypress.org/developer-docs/modifying-the-buddypress-admin-bar/

    = “Error! This blog has been archived or suspended.”

  • Profile picture of Suzanne Suzanne said 2 years, 5 months ago:

    Nice – thanks for the quick function Burt!

  • Profile picture of intimez intimez said 2 years, 2 months ago:

    I pasted Burt’s code to the end of function.php and I get a blank page

    Did I miss something?

    [wordpress2.9.2 + buddypress1.2.1]

  • Profile picture of intimez intimez said 2 years, 2 months ago:

    Anyone? Just looking for a little guidance so I can give this a try. Additional modification needed for the code? Need to paste it in a particuliar section of a file?

  • Profile picture of designodyssey designodyssey said 2 years, 2 months ago:

    Burt was using version 1 of BP. Sounds like some tweaking is necessary for V1.2