Re: Members Directory
The last time i fooled around with the member theme at the sidebar/widget level I couldn’t use dynamic sidebars. It was just flatly impossible. Seems things have changed. I’ve gotten them running in the member theme but have only been able to select sidebars that are defined in whatever theme I have defined for the wp blog id 1 theme.
Like I say it’s been quite awhile since I looked at this problem and to my surprise it actually works now. Sort of, with restrictions, kinda. Perhaps I’m just doing it the wrong way. I’ll tell you how I got it done.
The problem really is that the member theme isn’t a real registered theme. You only get one theme per blog with wp. That one is the one activated for that particular blog. I currently have the bp home theme registered for blog id 1. It registers 3 sidebars and those are the ones that are available for the theme.
The bp member theme doesn’t register any sidebars by default and doesn’t include the default sidebar template file either. I suggested above that you use the sidebar template from the home theme. That alone was not enough to get widgets into the member theme. I stuck the normal code for using dynamic sidebars into the sidebar template like this:
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
<?php endif; ?>
That got me exactly nothing. So I included sidebar registration code in the member theme’s functions.php file where it normally gets put.
register_sidebars( 1,
array(
'name' => 'member-sidebar',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>'
)
);
I named my new sidebar ‘member-sidebar’ thinking that it would show up in the back end of wp where I could then register some widgets for my ‘member-sidebar’. Nope. The ‘member-sidebar’ doesn’t show up.
I did get the first sidebar to display in the member theme though. Whatever was defined in the wp theme as the first registered sidebar, showed in the member theme. Well this is progress ‘eh? Something is showing in the member theme. I had to mod the member theme css to have it appear though. The #sidebar div isn’t in the base.css for the member theme. I modified the #content div in base.css and included the new #sidebar div.
Still with me? Now I have *a* sidebar with widgets in the member theme. Well I don’t want just any widgets, I want to specify what specific widgets get displayed right? Anyway I finally figured out that I have to register *all* the same sidebars that the wp theme on blog id 1 register. I copied all the function.php sidebar registration calls from the home theme’s function.php and stuffed them into the member theme’s function.php.
Works like a charm. Now in my member theme template file plugin-sidebar.php I can specify which sidebar I want to display.
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('blog-sidebar') ) : ?>
That above just happens to be the one I chose to test that I could have any sidebar I wanted in that template. Works. Well, I didn’t want one of those sidebars at all. I wanted a separate sidebar for my member theme. ‘member-sidebar’. That would not show up until I included the registration function in both the home theme and the member theme. Then I get to change the code above to be ‘member-sidebar’.
Like I said I may be doing this all wrong and hope that someone comes up with a better solution but this is the one that works for me.
1) Add another register sidebar call to the wp theme running on blog id 1. Like this in your blog id 1 functions.php file:
register_sidebars( 1,
array(
'name' => 'member-sidebar',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>'
)
);
I stuck that under the other 3 calls in the default home theme.
2) Copy *all* the register_sidebars() calls from the home theme functions.php file to the member theme’s functions.php file. They should look the same now when it comes to sidebar registration calls.
3) Copy the sidebar template file that is distributed with the home theme plugin-sidebar.php to the member theme dir.
4) Modify the plugin-template.php file in the member theme to load the new sidebar template also.
<?php get_header() ?>
<div class="content-header">
<?php do_action('bp_template_content_header') ?>
</div>
<div id="content">
<h2><?php do_action('bp_template_title') ?></h2>
<?php do_action('bp_template_content') ?>
</div>
<?php bp_get_plugin_sidebar(); ?>
<?php get_footer() ?>
That’s my plugin-template.php file that lives in my member theme.
5) Modify the plugin-sidebar.php template in the member theme to look like this:
<div id="sidebar">
<?php do_action('bp_template_sidebar') ?>
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('member-sidebar') ) : ?>
<?php endif; ?>
</div>
6) Modify the member theme css to include the new #sidebar div that didn’t exist before. I just did it this way for the content and sidebar divs:
#main #sidebar{
margin-left:70%;
margin-right:20px;
}
#main #content {
float: left;
width: 65%;
position: relative;
padding: 2em 3em;
}
Use whatever is appropriate for your member theme.
7) Fire up the back end of wp and add widgets to the ‘member-sidebar’. Enjoy your new member theme sidebar.