Skip to:
Content
Pages
Categories
Search
Top
Bottom

Groups tab…add most recent post blurb under group description.


  • Pisanojm
    Participant

    @pisanojm

    Need a how to… How can I add the latest group discussion directly underneath the group description when viewing the group tab off of the main page? Not unlike when viewing the members tab and seeing the latest update next to each member…

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

  • Pisanojm
    Participant

    @pisanojm

    @r-a-y @boonegorges any thoughts as to the above?


    Boone Gorges
    Keymaster

    @boonebgorges

    Put a bp_has_forum_topics() loop inside of the groups loop, and feed in the argument max=1. See https://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-forum-topics-loop/


    Pisanojm
    Participant

    @pisanojm

    So I looked at this and it looks like it would be more difficult that I expected… It doesn’t look like there is an easy way to differentiate which topic to pull… that is using the bp_has_forum_topics () loop I can pull the most recent of all the topics, but there is no easy way to pull the most recent topic from among the forums within the group without some major re-write magic….

    Just to clear it up, what I’m trying to do… here is a pict:
    http://mustech.net/holder/grouptopic.jpg

    So the most recent topic would be previewed for each group listed in the group directory in the area specified…


    Pisanojm
    Participant

    @pisanojm

    @boonebgorges If you get a chance would you mind putting your “mind” on this again for a few minutes? Is it a lost cause? It’s not critical for me, but I would like to be able to do it. RE: latest topic preview in the groups page underneath each group name.

    a little quick tip i did to display the latest activity for a group
    http://etivite.com/groups/buddypress/forum/topic/quick-tip-display-the-groups-recent-activity-on-group-directory-groups-loop/#topic

    but this is using the activity stream content – so to filter the activity content to just forum topics: change the line ‘action’ => false to ‘action’ => ‘new_forum_topic’ you may need to tweak some other stuff (content, title, etc)

    see how it works here:
    http://etivite.com/groups/


    @mercime
    Participant

    @mercime

    @Pisanojm re “latest topic preview in the groups page underneath each group name”
    solution at this thread with some adjustment may be the ticket for you – https://buddypress.org/community/groups/creating-extending/forum/topic/show-by-latest-post-by-group/


    Pisanojm
    Participant

    @pisanojm

    @nuprn1 @mercime @boonebgorges

    Thank you for leading me to the code to get to this… I basically just did a super-slight mod of Rich’s code. Here is what I used and I put it in the the bp-custom.php file in the plugins directory:

    `<? function my_group_loop_activity_item() {

    global $bp, $activities_template;

    if ( !bp_is_active( ‘activity’ ) )

    return;

    if ( !bp_group_is_visible() )

    return;

    $show_hidden = false;

    /* Group filtering */

    $object = $bp->groups->id;

    $primary_id = bp_get_group_id();

    if ( ‘public’ != $bp->groups->current_group->status && groups_is_user_member( $bp->loggedin_user->id, bp_get_group_id() ) )

    $show_hidden = true;

    /* Note: any params used for filtering can be a single value, or multiple values comma separated. */

    $defaults = array(

    ‘display_comments’ => false, // false for none, stream/threaded – show comments in the stream or threaded under items

    ‘sort’ => ‘DESC’, // sort DESC or ASC

    ‘page’ => 1, // which page to load

    ‘per_page’ => false, // number of items per page

    ‘max’ => 1, // max number to return

    ‘include’ => false, // pass an activity_id or string of ID’s comma separated

    ‘show_hidden’ => $show_hidden, // Show activity items that are hidden site-wide?

    /* Filtering */

    ‘object’ => $object, // object to filter on e.g. groups, profile, status, friends

    ‘primary_id’ => $primary_id, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.

    ‘action’ => ‘new_forum_topic’, // action to filter on e.g. activity_update, new_forum_post, profile_updated

    ‘secondary_id’ => false, // secondary object ID to filter on e.g. a post_id

    /* Searching */

    ‘search_terms’ => false // specify terms to search on

    );

    $r = wp_parse_args( $args, $defaults );
    extract( $r );

    $filter = array( ‘user_id’ => false, ‘object’ => $object, ‘action’ => $action, ‘primary_id’ => $primary_id, ‘secondary_id’ => $secondary_id );

    $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden );

    while ( bp_activities() ) : bp_the_activity(); ?>

    <div class="item-descb" id="activity-“>

    Latest Topic Activity in the Group:

    <a href="”>

    <?php endwhile;

    }

    add_action( ‘bp_directory_groups_item’, ‘my_group_loop_activity_item’ );
    ?>`

    I also added this to the default.css to give me a little more control of the output (changed the div in the original to match below):

    ` ul.item-list li div.item-descb {
    margin: 10px 0 0 64px;
    font-size: 11px;
    color: #888;
    width: 85%;
    }
    `

    THANKS AGAIN! Here is a pict completed:
    http://mustech.net/holder/grouptopic2.jpg

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Groups tab…add most recent post blurb under group description.’ is closed to new replies.
Skip to toolbar