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)