Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re-do output bp_activity_content()


  • Xevo
    Participant

    @xevo

    Hey Buddypress community,

    I want to redo the output of the function bp_activity_content, I need another output from the function. I have an example of how it’s suppose to look (http://i36.tinypic.com/263hvfb.png), so basicly, I just need; the time in hours/minutes (which I float to right) – Delete (displayed as [D]) – username – event (as a link which links to the event). All on one line offcourse, I believe this looks better then such a huge activity stream with images and excerpts.

    I tried preg_replace, but didn’t come far with that. Can someone help me with doing this?

    Thanks,

    Mitchell

Viewing 4 replies - 1 through 4 (of 4 total)

  • Xevo
    Participant

    @xevo

    Bump, still havent found a solution for this.

    All of the content that is output with bp_activity_content() is stored in the database. This is mostly for performance reasons. If this data had to be recreated on each page load, you’d be looking at hundreds and hundreds of queries.

    You can modify it with a filter though, but you’re limited to string replacement and css modifications:

    function my_function( $content ) {
    return $content; // do something with the content first
    }
    add_filter( 'bp_get_activity_content', 'my_function' );

    You can put this in your own plugin, or in bp-custom.php.


    Xevo
    Participant

    @xevo

    Ok, I’ll try writing my first ever wordpress function then. :)

    Thanks for pointing me in the right direction.


    Xevo
    Participant

    @xevo

    For the people that are interested, here’s what I ended up doing.

    function get_activity_flatline( $content ) {
    $striptags = array("<p>", "</p>");
    $content2 = str_replace($striptags, "", $content);
    $content3 = substr($content2, 0, strpos($content2, '<span class="time-since">'));
    return $content3;
    }
    add_filter( 'bp_get_activity_content', 'get_activity_flatline' );

    Not pretty or anything, but it works for me. If you want the time to keep being displayed, change the <span class="time-since"> into

    <blockquote>.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Re-do output bp_activity_content()’ is closed to new replies.
Skip to toolbar