Codex Home → BuddyPress Theme Development → Activity dropdown filters in templates
Activity dropdown filters in templates
Activity dropdown filters are used in order to let a user filter the activity stream in three main contexts: the activity directory, the single member activity page and the single group activity page.
The Activity directory dropdown filters.
Version 2.1 of BuddyPress introduced the template tag bp_activity_show_filters() to dynamically generate the options of the activity dropdown filters. While the BP Theme compatibility templates are using this function, the BP-Default templates are not since Core Team has decided that no further development on the theme template files will be made. The goal of this article is to show you how you can enjoy this new template tag within your BP-Default child theme.
Use bp_activity_show_filters() within your BP-Default child theme
The three templates that are containing an activity dropdown filters are:
Activity directory: activity/index.php
Single Member activity page: members/single/activity.php
Single Group activity page: groups/single/activity.php
Let』s look at the activity directory template, focusing on the select tag having the css id 「activity-filter-by」:
As you can see, this part is checking if the component is active before displaying its actions which are then hardcoded in the template. If you are using, at least, BuddyPress 2.1 you can edit the templates to use the template tag bp_activity_show_filters() instead of the hardcoded options (except for the first one). Once done, the activity/index.php and members/single/activity.php will have a select tag looking like this:
For the groups/single/activity.php template, the only difference is that the bp_activity_show_filters() template tag is including a context parameter set to 『group』 like this:
Why using bp_activity_show_filters() within your theme』s templates
As soon as you are using at least version 2.1 of BuddyPress, you should consider using this new template tag as it will be used by BuddyPress to create new activity actions for its current (and future) components. BuddyPress plugins might also progressively rely on this template tag as setting activity actions have been greatly improved thanks to the function bp_activity_set_action().
Related Resources
bp_activity_set_action() codex page
Posting activities from plugins, section 「Fully enjoy bp_activity_set_action()」