Skip to:
Content
Pages
Categories
Search
Top
Bottom

Members Directory


  • gcs123
    Participant

    @gcs123

    I’m having a few issues with my members directory with my sidebars.

    I’m using the most recent skeleton member theme and buddypress 1.0

    Remember in the last release you called the bp-plugin sidebar?

    What is the option to do this in the new 1.0 release? Do we have to copy any files from anywhere?

    Thanks

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

  • Burt Adsit
    Participant

    @burtadsit

    The 1.0 member theme plugin-template.php doesn’t include the sidebar. You’ll have to copy the plugin-sidebar.php template over to the member theme dir. Also the plugin-template.php file doesn’t include the call to launch it. If you look at the home theme’s plugin-template.php file you’ll see the difference. It has a diff set of divs and a call to bp_template_sidebar() which you’ll have to include in the member theme’s plugin-template.php.

    You do know that this doesn’t really setup a normal wp sidebar were you can install widgets from the back end of wp right? All the sidebar does is trigger an action that you have to trap in your code.


    gcs123
    Participant

    @gcs123

    Forgive my ignorance but im a bit confused!

    how can I set up sidebars then to include the widgets? At the minute my members directory page is looking a bit odd without the sidebars to complete the design.


    Burt Adsit
    Participant

    @burtadsit

    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.


    Burt Adsit
    Participant

    @burtadsit

    That\’s how I got the member theme to display a sidebar using the plugin-template.php and plugin-sidebar.php templates. You\’ll have to modify the directory templates to display a sidebar if you want them to show up there. All you have to do is include the sidebar div like:

    <div id="sidebar">
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('member-sidebar') ) : ?>
    <?php endif; ?>
    </div>

    I stuck that each directory’s index.php template and modified the css to format things properly. Giving the new sidebar some room.


    Burt Adsit
    Participant

    @burtadsit

    Once again the major restriction I’ve found is that the functions.php files in both the member theme and the home theme *must* register the same sidebars. They have to match. The member theme can not independently register a sidebar that doesn’t exist for blog id 1.

    I can live with that. :)


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    This makes sense, because like you said above, the Member Themes aren’t real WordPress themes; BuddyPress just muscles itself in and takes over the place. And as long as the member theme functions.php registers a sidebar with the same name, WP doesn’t know the difference and loads it up.

    It’s posts like this, Burt, that lead me to believe that there’s a whole lot of progress that will be made in modifying the Member Theme area.

    Good post, A+ for the day. :D


    Burt Adsit
    Participant

    @burtadsit

    It used to be that wp didn’t consider the member theme a theme at all. It still doesn’t. Andy is temporarily tricking wp by trapping a couple of filter calls that wp uses to find the current theme. Looks like when we are in the member theme wp temporarily thinks it’s the current theme.


    r-a-y
    Keymaster

    @r-a-y

    Sorry for bumping this thread! But it’s a great resource for figuring out how to get WP widgets working in a BP Member Theme!

    Thanks to Burt for figuring this out!

    Apologies if the bump is uncalled for.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Members Directory’ is closed to new replies.
Skip to toolbar