Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#5393 closed enhancement (fixed)

Introduce new filter in bp_get_group_description_excerpt() for setting the excerpt_length

Reported by: lenasterg Owned by: boonebgorges
Priority: low Milestone: 2.0
Component: Groups Version: 1.9.2
Severity: minor Keywords:
Cc:

Description

Setting the length of group description excerpt isn't easy if you want to keep the output format of bp_create_excerpt().
It can be more easier for theme developers, by setting the length using a filter (similar to the bp_activity_excerpt_length filter).

Attached is the suggested filter addition.

Attachments (1)

bp-groups-template.php.patch (839 bytes ) - added by lenasterg 12 years ago.
New filter bp_group_description_excerpt_length

Download all attachments as: .zip

Change History (5)

@lenasterg
12 years ago

New filter bp_group_description_excerpt_length

#1 @boonebgorges
12 years ago

  • Milestone Awaiting Review2.0

I'd rather not set a precedent of creating a specific filter for excerpt_length every time we call bp_create_excerpt().

What we can do to make this easier for you is to pass the $group object along to the filter. So then you can do this:

function bbg_custom_group_description_excerpt( $excerpt, $group ) {
    $excerpt = bp_create_excerpt( $group->description, 100 );
}
add_filter( 'bp_get_group_description_length', 'bbg_custom_group_description_excerpt', 10, 2 );

#2 @boonebgorges
12 years ago

  • Owner set to boonebgorges
  • Resolutionfixed
  • Status newclosed

In 7865:

Pass $group object to bp_get_group_description_excerpt filter

This allows theme/plugin authors to more easily customize excerpts.

Fixes #5393

#3 @lenasterg
12 years ago

Thanks boonebgorges!

Just a small note to be sure. In your example you mean:

function bbg_custom_group_description_excerpt( $excerpt, $group ) {
    $excerpt = bp_create_excerpt( $group->description, 100 );
    return $excerpt;
}
add_filter( 'bp_get_group_description_excerpt', 'bbg_custom_group_description_excerpt', 10, 2 );

which is working OK with the changes you made in 7865.

P.S.
You are great!!!

#4 @boonebgorges
12 years ago

Ha, yes, you must return the value. Thanks for pointing it out, and thanks for your contributions!

Note: See TracTickets for help on using tickets.