Template Tags Suggestion
-
I have a suggestion for many of the template tags functions, which will probably save people a heck of a lot of time when tweaking/creating themes.
I found that when making my own theme, a huge issue is the functions that give the list of options, header tabs, etc. only offer a certain format, usually lists. These functions generate the lists themselves.
My suggestion is that these functions call another function that supplies an array of the items which then turns it into an unordered list. That way we can call that function and do whatever we want with the links (filter, different structure, etc.).
I’ve made a few for myself already (would be happy to forward them for inclusion), but here’s an example of what I did for the bp_groups_header_tabs(). The original function could grab this array and make the list fairly easily.
(Sorry, when I use the code markup it doesn’t format it very well)
<br />
function bp_get_groups_header_tabs() {
global $bp, $create_group_step, $completed_to_step;
$array = array(
'recently-active' => array( 'text' => __( 'Recently Active', 'buddypress' ) ),
'recently-joined' => array( 'text' => __( 'Recently Joined', 'buddypress' ) ),
'most-popular' => array( 'text' => __( 'Most Popular', 'buddypress' ) ),
'admin-of' => array( 'text' => __( 'Administrator Of', 'buddypress' ) ),
'mod-of' => array( 'text' => __( 'Moderator Of', 'buddypress' ) ),
'alphabetically' => array( 'text' => __( 'Alphabetically', 'buddypress' ) )
);
//Add links and current check dynamically, takes up less space this way.
foreach($array as $key => $value){
$array[$key]['link'] = $bp->displayed_user->domain . $bp->groups->slug . '/my-groups/' . $key;
$array[$key]['is_current'] = ( $key == $bp->action_variables[0] );
}
return $array;
}
- The topic ‘Template Tags Suggestion’ is closed to new replies.