Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Solved: set a character limit on activity content? (6 posts)

Started 1 year, 1 month ago by: nit3watch

  • Profile picture of nit3watch nit3watch said 1 year, 1 month ago:

    Iv’e build a plugin that returns the activity ( set it to scope=groups ) similar to twitters homepage vertical scrolling feed.

    The problem is it is displayed in some what of a small area and I would like them to be uniform in size; because if there’s a large activity post, it takes up the entire ‘widget space’. Also the js assigns the height to all elements based on the ‘tallest’ one, so there’s a lot of white space ( if there is a large post in the stream ).

    I had a look at the codex though couldn’t find anything relative to what I need, and ideas?

  • Profile picture of nit3watch nit3watch said 1 year, 1 month ago:

    well this is what I came up with, though it doesn’t work. Help would greatly be appreciated.

    function bp_limit_group_activity_content() {
    
    $g_activity_desc = bp_activity_content_body();
    
    $limit_desc = substr($g_activity_desc,0,10);
    
    return $limit_desc;
    }
  • Profile picture of nit3watch nit3watch said 1 year, 1 month ago:

    Found a solution, just cleaning up the function and adding ‘read more’ and so on, will post it when im done.

  • Profile picture of nit3watch nit3watch said 1 year, 1 month ago:

    working nicely, just need to filter out ‘joined the group.. and created group.. and remove ‘view’ and delete’.

    Once im done using it for what i need ill turn it into a widget for the community :D

    function bp_limit_group_activity_content() {
    
    $group_activity_length = 100; //character limit
    
    $group_excerpt = substr(bp_get_activity_content_body(), 0, $group_activity_length); //truncate excerpt according to lenngth
    if(strlen($group_excerpt) < strlen(bp_get_activity_content_body())) {
        $group_excerpt = $group_excerpt.'..' ;
    }
    
    echo "<p>".$group_excerpt."</p>"; //finally display excerpt
    }

    and then calling it by

    <?php if ( bp_has_activities('scope=groups') ) : ?>
    <div id="news-container">
    
    	<ul id="activity-stream" class="activity-list item-list">
    
    	<?php while ( bp_activities() ) : bp_the_activity(); ?>
    
    		<li class="<?php bp_activity_css_class() ?>" id="activity-<?php bp_activity_id() ?>">
    
    			<div class="activity-content">
    
    				<div class="activity-header">
    					<?php bp_activity_action() ?>
    				</div>
    
    				<a href="<?php bp_activity_thread_permalink() ?>"><?php bp_limit_group_activity_content() ?></a>
    
    				<?php do_action( 'bp_activity_entry_content' ) ?>
    
    			</div>
    		</li>
    
    	<?php endwhile; ?>
    
    	</ul>
    </div>
    <?php else : ?>
    	<div id="message" class="info">
    		<p><?php _e( 'Join groups to get feed.', 'buddypress' ) ?></p>
    	</div>
    <?php endif; ?>
  • Profile picture of nit3watch nit3watch said 1 year, 1 month ago:

    one thing I over-looked is limiting the line height, Im going to look into this tomorrow though if anyone knows of a solution please don’t be shy :P

    Also is there a filter specific to group updates only, thus excluding ‘joined group’ and ‘created group’?

  • Profile picture of tonydbaker tonydbaker said 11 months ago:

    Did you ever create a wordpress/buddypress plugin for this? I need to limit characters on activity, but I’m not a programmer. I can activate a plugin though! Also, I need to limit characters on a couple of custom profile fields. Thanks and Let me know!