Add a new Tab
-
Hello
how can I add another Tab to this page:
mysite.com/forumsAll Topics | Another Forum loop
I want to have modified forum loop
-
no solution?
I tried to do something with the skeleton compenent without success
@tubruk – Check out bp-themes/bp-default/forums/index.php.
In that file is a hook to add more tabs:
eg. Add this to your theme’s functions.php:
function my_new_fantabulous_forum_tab() { ?> <li id="forums-newttab no-ajax"><a href="YOUR LINK">Another Forum Loop</a></li> <?php } add_action( 'bp_forums_directory_group_types', 'my_new_fantabulous_forum_tab' );
If you want your tab to be AJAX-ifed, you’ll need to remove the “no-ajax” CSS class from the tab and write an AJAX hook as well.
Check out the “bp_dtheme_ajax_querystring” filter in /bp-default/_inc/ajax.php. It’s a little complicated, but once you get the jist of it, it makes things a little easier.
There’s a few posts on these forums about it:
http://www.google.com/search?hl=en&hs=6eV&rls=en&channel=suggest&q=%22bp_dtheme_ajax_querystring%22+filter&aq=f&aqi=&aql=&oq=Hopefully that helps somewhat.
<li id="forums-newttab no-ajax"><a href="YOUR LINK">Another Forum Loop</a></li>
@r-a-y thank you very much. What is “MY LINK” ? I created another forum loop but whats the url of it?
I only changed this in the new forum loop.php :
“YOUR LINK” is the link you want to set. This is only useful if you want to link to a new page (like your new forum loop) and you don’t want to use AJAX.
However, it seems like you want to use AJAX, so you’ll have to manipulate the AJAX querystring so BuddyPress knows how to load your new custom forum loop. If you go this route, remember to remove the “no-ajax” CSS class from your tab.
The way you name your tab class is important.
In the example above, “forums-newtab”, BP’s AJAX will see “newtab” as the forum’s scope. You’ll then need to manipulate the AJAX querystring to add your forum IDs only when the forum scope is set to “newtab”.
Check out the bp_dtheme_ajax_querystring() in /bp-default/_inc/ajax.php and try to analyze lines 43-50. See how when the scope is set to “personal” that BP changes the `user_id`. You’ll need to do something similar with the `forum_id` parameter when the `scope` is set to “newtab” and when the `object` is set to “forums”.
Once you get a grasp of this, then you can write your filter to do your manipulation.
@r-a-y thank you very much I found a way and it works fine :
1. in ajax.php I added this:
if ( 'english' == $_BP_COOKIE ) { $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id; $qs[] = 'forum_id=17'; }
2. Then added this in forums/index.php :
<li id="forums-english"><a href="">English</a></li>
thanks again. I hope this will help other members too.
<li id="forums-newttab no-ajax"><a href="YOUR LINK">Another Forum Loop</a></li>
Not allowed to have two tokens to an ID should be ID and a class for the ‘no-ajax’ token if required?
When I click the New Tab button and visit a group I get the forum topics of that tab and not the group???
Sorry hnla, you’re right; if you’re not using ajax, the code should be:
<li id="forums-newttab" class="no-ajax"><a href="YOUR LINK">Another Forum Loop</a></li>
tubruk – if you upgrade BP, you will lose your changes made to bp-default/_inc/ajax.php. I would recommend the filter available in the bp_dtheme_ajax_querystring() function.
thanks will do that….
What exactly is wrong? When I click the NEW TAB button and visit a group I get the forum topics of that “NEW TAB”??
- The topic ‘Add a new Tab’ is closed to new replies.