Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Buddypress Widget WordPress

  • SOLVED

Hi,
I need to add a widget on the sidebar with 3 streams from buddypress (bbpress) topics forum.

most active topic stream
most new topic stream
most view topic stream

We need to embed some template tags or query_posts to display these bbpress topics...
I don't know if it is possible to modify actual widget or use text widget to embed the template tags to call the excerpt of 1 post of each 3 streams ?



Buddypress Widgets are “activity members or groups oriented” ...



Here are some interested links :
http://codex.buddypress.org/developer-discussions/buddypress-template-tags/
http://wordpress.org/extend/plugins/buddypress-widget-pack/
http://buddypress.org/community/groups/buddypress-skeleton-component/
http://buddypress.org/community/groups/buddypress-sitewide-activity-widget/
http://buddypress.org/community/groups/enhanced-buddypress-widgets/

Thanks

Answers (1)

2010-08-01

Pippin Williamson answers:

Is the widget going to be displayed on a buddypress site or on a non buddypress site?


angang comments:

Buddypress is integrated like a "super forum" section on a site, so I want to say non Buddypess site. But the Buddypress is installed on this wordpress site.


Pippin Williamson comments:

This looks like it might do everything you need:

http://wordpress.org/extend/plugins/buddypress-group-forum-extras/


angang comments:

Thanks Pippin,

this is a good plugin.

The widget function "latest topics" should be interesting to have :

most active topic stream
most new topic stream
most view topic stream


I have found the widget loop @ bp-forum-extras-index.php line 315 to 322 :



<?php while ( bp_forum_topics() ) : bp_the_forum_topic(); ?>
<li>
<div class="item">
<div class="item-title"><a class="topic-title" href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php echo bp_create_excerpt( bp_get_the_topic_title(), 8) ?></a></div>
<span class="description">&ndash; posted in <a href="<?php bp_the_topic_object_permalink() ?>" title="<?php bp_the_topic_object_name() ?>"><?php bp_the_topic_object_name() ?></a></span>
</div>
</li>
<?php endwhile; ?>





Now, what should we have in this loop or others to show the 3 streams ?

Thanks again Pippin



Pippin Williamson comments:

The plugin I linked to already has support for displaying the most recent topic.

To show the most popular topics, change line 312 from


if ( bp_has_forum_topics( 'page=false&max='. $instance['forum_latest_limit'] ) ) : ?>

to

if ( bp_has_forum_topics( 'page=false&type=popular&max='. $instance['forum_latest_limit'] ) ) : ?>


Note that this will make the latest topic widget display the latest most popular topics. It may be better to create a second widget (just duplicate the entire widget code) and change the loop for that one so that you can still have the plain latest topics widget as well.

Read this for more reference: http://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-forum-topics-loop/


angang comments:

Pippin, Very sorry for the delay, i had loose my osx system disk and have just receive SSD replacement.
I try to make as fast as possible to reinstall all my stuff from backups and test your propositions that seems great.

Thank you for your answer


angang comments:

Ok, i have tried and it seems to work for the most popular stream.

Now i am not sure about "(just duplicate the entire widget code)".. I have duplicate the plugin folder and renamed bp-forum-extras-index.php @ line 3 like this :
>Plugin Name: BuddyPress Forums Extras - Forums Index - Popular
>Plugin Name: BuddyPress Forums Extras - Forums Index - Recent

But, there is something wrong with the duplication of function :
Fatal error: Cannot redeclare bp_forum_extras_index_setup_globals()
(previously declared in /wp-content/plugins/buddypress-group-forum-extras - recent/bp-forum-extras-index.php:20)
in /wp-content/plugins/buddypress-group-forum-extras - popular/bp-forum-extras-index.php on line 38


Could you explain me how to avoid this redeclaration problem ?


angang comments:

Ok, the solution to use the widget with 2 queries is not to duplicate the plugin, but to insert new query after the first like that





if ( bp_has_forum_topics( 'page=false&type=popular&max='. $instance['forum_latest_limit'] ) ) : ?>
<ul id="widget-topic-list" class="item-list">
<?php while ( bp_forum_topics() ) : bp_the_forum_topic(); ?>
<li>
<div class="">
<div class="item-title">
<a class="topic-title" href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>">
<?php echo bp_create_excerpt( bp_get_the_topic_title(), 8) ?><br />
<?php bp_the_topic_latest_post_excerpt() ?></a>
</div>
<span class="description">in <a href="<?php bp_the_topic_object_permalink() ?>" title="<?php bp_the_topic_object_name() ?>"><?php bp_the_topic_object_name() ?></a></span>
</div>
</li>
<?php endwhile; ?>
</ul>
<?php else: ?>
<div>
<p><?php _e( 'Sorry, there were no forum topics found.', 'buddypress' ) ?></p>
</div>
<?php endif;





if ( bp_has_forum_topics( 'page=false&type=newest&max='. $instance['forum_latest_limit'] ) ) : ?>
<ul id="widget-topic-list" class="item-list">
<?php while ( bp_forum_topics() ) : bp_the_forum_topic(); ?>
<li>
<div class="">
<div class="item-title">
<a class="topic-title" href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>">
<?php echo bp_create_excerpt( bp_get_the_topic_title(), 8) ?><br />
<?php bp_the_topic_latest_post_excerpt() ?></a>
</div>
<span class="description">in <a href="<?php bp_the_topic_object_permalink() ?>" title="<?php bp_the_topic_object_name() ?>"><?php bp_the_topic_object_name() ?></a></span>
</div>
</li>
<?php endwhile; ?>
</ul>
<?php else: ?>
<div>
<p><?php _e( 'Sorry, there were no forum topics found.', 'buddypress' ) ?></p>
</div>
<?php endif;