Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] How to set individual sidebars for individual groups


  • Stingray1972
    Participant

    @stingray1972

    I have 21 groups that i need to set a specific sidebar for. How can i do this? The info needs to be different on each groups sidebar. Is there a wAy that this can be done without hard coding and if it needs to be coded how do i do this? I am very new to php and buddypress so a real clean (for idiots) response would be great.

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)

  • danbp
    Moderator

    @danbp

    hi @stingray1972,

    How to get different infos in 21 group sidebars for Dummies.

    TIP-OFF: we won’t built 21 sidebars, but only 21 different informations useable from within 21 groups.

    We assume you have a theme with at least one sidebar and that this sidebar is visible when you’re on a group page.
    We assume also that you have a child-theme, because we’re going to add some modification to it. And this must be done in a child or you loose any changes at the next theme update.

    Now that we have set the stage, let’s go further.

    1) we have a sidebar
    2) we need a place to set our extra information
    3) we need a function to insert the info at the right place

    You follow ? Not to hard ? Ok, let’s continue…

    – Make a copy of the original sidebar.php of your theme into the child-theme folder.
    – open the copy and search in the code something like this: dynamic_sidebar( 'sidebar' )
    – underneath you paste this:

    <?php if ( bp_is_groups_component() ) : 
    			do_action( 'xtragroup' ); 
    		endif; ?>

    – save the file.

    Bravo ! You have installed a new placeholder in the widget area.

    The result should look like this:

    
    	<div id="tertiary" class="sidebar-container" role="complementary">
    		<div class="sidebar-inner">
    			<div class="widget-area">
    				<?php dynamic_sidebar( 'sidebar-2' ); ?>
    				
    <?php if ( bp_is_groups_component() ) : 
    			do_action( 'xtragroup' ); 
    		endif; ?>	
    	 
    			</div><!-- .widget-area -->
    		</div><!-- .sidebar-inner -->
    	</div><!-- #tertiary -->

    (example shows the code of the Twentythirteen widget area)

    – open the child-theme functions.php (if not exist you have to create it)

    – add the following snippet and save the file.

    function xtra_group_sidebar() {
    	
    	// conditionnal - group name (slug format) - item
    	if(bp_is_groups_component() && 'kill-bill' == bp_current_item() ):
    	// your content
    		echo 'what time is it Bill ? ' ;
    		$my_date = date('H:i'); echo $my_date; 
    	endif;
    	
    	if(bp_is_groups_component() && 'groupe-2014' == bp_current_item() ):
    		echo 'who knows ?';
    	endif;
    	
    	if(bp_is_groups_component() && 'rrrrrrrr' == bp_current_item() ):
    		echo 'Groaaaar...';
    	endif;
    }
    add_action( 'xtragroup', 'xtra_group_sidebar' );

    – Be carefull: the snippet handles only 3 group.
    – You have to add 18 more and change the names to those you use.
    – Simply replicate for each the if (bp_is_groups_component(), the echo (or anything else) and the endif
    – upload to the server and enjoy !

    EFD (end for dummies)


    Stingray1972
    Participant

    @stingray1972

    Hi, many thanks for this code. Would this work with using the group ‘ID’ rather than group ‘NAME’?. So in short this will add 21 new sidebars effectively into my widgets page that i can then drop widgets into? If i gave you all the goup ID’s for the sidebars needed could you throw the php code together for me? Would be a great help.


    Stingray1972
    Participant

    @stingray1972

    Hi, below is what is in my ‘sidebar.php’ file…

    <?php
    /**
    * Sidebar
    *
    * @package WordPress
    * @subpackage TDFramework
    * @since framework 1.0
    */

    global $core_sidebars;

    $sidebar_slug = core_layout_current_sidebar();

    if (!$sidebar_slug)
    return;

    if (!dynamic_sidebar($sidebar_slug))
    //core_warning( __(‘Sidebar with name’, THEME_SLUG) .’ “‘ .$core_sidebars[$sidebar_slug]. ‘” ‘. __(‘not found, or has no widgets assigned to it.’, THEME_SLUG));

    ?>

    could you please show me where the code would go?


    danbp
    Moderator

    @danbp

    Asking for help and guidance is OK. But asking for doing the job at your place is something completely different. How much do you estimate my work ? The one already done and the one you ask for now ? If you need a professionnal, you can post on the Job Board to hire a freeelancer.

    I told you how to accomplish it.
    You use a theme that i even don’t know the name, and which is most probably a Premium theme.
    How to customize it is certainly explained on the theme support. And if it’s Premium, you already payed for this service, so use it and if you don’t know, ask there.


    Stingray1972
    Participant

    @stingray1972

    Hi Dan BP,

    Sorry to be such a pain… here is a link to the 2 files that need altering. These are the two files specific to my theme which is ‘MikMag’

    https://www.dropbox.com/s/vddx1qg79fa3us7/Archive%202.zip

    Would it be ok for you to alter these two files so that they produce the correct result as i am having no joy.

    Many thanks for your help its much appreciated.


    danbp
    Moderator

    @danbp

    Did you read and understood my previous answer ?


    Stingray1972
    Participant

    @stingray1972

    Yes I, am a member of WPMU so hoping they will move this forward for me.

    Thanks for starting the process.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] How to set individual sidebars for individual groups’ is closed to new replies.
Skip to toolbar