Skip to:

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#5393 closed enhancement (fixed)

Introduce new filter in bp_get_group_description_excerpt() for setting the excerpt_length

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


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 10 years ago.
New filter bp_group_description_excerpt_length

Download all attachments as: .zip

Change History (5)

10 years ago

New filter bp_group_description_excerpt_length

#1 @boonebgorges
10 years ago

  • Milestone changed from Awaiting Review to 2.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
10 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

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
10 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.

You are great!!!

#4 @boonebgorges
10 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.