Forum Replies Created
-
@modemlooper Okay, so I am probably going to get into moving to Buddy-default today. My concern is I am overriding templates from pre 2.0 (bp-default). Is there any way I can conserve these custom templates I’ve made and move to Buddy-default, or am I just going to have to manually (read, S.O.L) lol
In reply to: Why do members loops include the current user?Ah, the counts are now fixed. Thanks @mercime but the user I am currently logged in as is still showing up in both the friends and members loops :/
In reply to: Why do members loops include the current user?On a related note, the count number on the members directory “My Friends” tab is incorrect. Is this likely/possibly a related problem?
Thanks @modemlooper, will try to look into changing this and will post results here. Got some bigger fish to fry before I can move on to this.
so just to reiterate, BP-Default and Buddy-Default are different themes? @imath said not to use BP-defauilt for it to work.
In reply to: Notifications template missing in 2.0?No, I found it. I was just being absentminded
In reply to: Notifications template missing in 2.0?I’m dumb, was in the wrong directory/was editing wrong notifications loop.
../members/single/notifications
In reply to: threaded comments also show up as top levelI took a very hacky approach to the activity-loop.php
changed:
<?php bp_get_template_part( 'activity/entry' ); ?>to:
<?php if(bp_get_activity_type() != "activity_comment"): ?> <?php bp_get_template_part( 'activity/entry' ); ?> <?php endif; ?>This will almost guaranteed cause problems in the loop keeping track of how many activities there are to display.
I definitely don’t see the correct admin-ajax call (there is one being called periodically, but that is originating from a plugin of mine that checks for new notifications).
I am in fact using a child of BP-default. Bummer 🙁
How/what theme do I have to be using for it to work? I was under the impression BP just defaulted to BP-default (lol) but maybe I don’t fully understand the bp theming process
It doesn’t happen at all and yes, it is turned on
In reply to: threaded comments also show up as top levelThe above code causes a problem w/ ajax commenting; the content doesn’t immediately display which is a bit troublesome. Any better solution?
In reply to: Comment content not showing?*sigh*
Of course, as soon as I post this, I find the problem.
function my_hidden_activities($a, $activities) { //if admin we want to know //if (is_site_admin()) //return $activities; $nothanks = array('activity_comment'); foreach ($activities->activities as $key => $activity) { if (in_array($activity->type, $nothanks, true)) { unset($activities->activities[$key]); $activities->activity_count = $activities->activity_count-1; $activities->total_activity_count = $activities->total_activity_count-1; $activities->pag_num = $activities->pag_num -1; } } // Renumber the array keys to account for missing items. $activities_new = array_values( $activities->activities ); $activities->activities = $activities_new; return $activities; } add_action('bp_has_activities', 'my_hidden_activities', 1, 2 );The above code causes this problem. The code is attempting to hide comments from appearing as their own activity stream items. Any suggestions on how I can hide comments from appear anywhere except for in the thread they are nested in?
In reply to: threaded comments also show up as top levelSolution: credit to @lincme on the post https://buddypress.org/support/topic/filtering-out-activity-stream-stuff/
// Remove (hide) various activities from streams. function my_hidden_activities($a, $activities) { //if admin we want to know //if (is_site_admin()) //return $activities; $nothanks = array('activity_comment'); foreach ($activities->activities as $key => $activity) { if (in_array($activity->type, $nothanks, true)) { unset($activities->activities[$key]); $activities->activity_count = $activities->activity_count-1; $activities->total_activity_count = $activities->total_activity_count-1; $activities->pag_num = $activities->pag_num -1; } } // Renumber the array keys to account for missing items. $activities_new = array_values( $activities->activities ); $activities->activities = $activities_new; return $activities; } add_action('bp_has_activities', 'my_hidden_activities', 10, 2 );Thanks! I’m going to stick with my solution, just because I am already editing child-theme templates anyways, but I would probably throw my vote in for modemlooper’s solution over mine as a way to keep all modifications pretty centralized
In reply to: Can I change autocomplete?Valid, well I’ll take a crack at that. If someone already has a solution feel free to post it 😀
I’ll post my solution once implemented.
Wow, so I’m dumb (or at least not as good at googling as I once thought). So, the best most efficient way to do this is using buddypress query filters. No need to add a new tab. Here is the code I ended up with (by editing activity-loop.php)
$friends = friends_get_friend_user_ids( bp_loggedin_user_id() ); $friends[] = bp_loggedin_user_id(); $friends_and_me = implode( ',', (array) $friends ); $friends_and_me = '&user_id=' . $friends_and_me; ?> <?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ).$friends_and_me.'&sort=DESC') ) : ?>much simpler and don’t have to worry about functions breaking. Subsequently, I believe if for some reason this solution doesn’t work for you and you prefer one of the earlier ones I suggested, then check out https://codex.buddypress.org/developer/loops-reference/the-activity-stream-loop/#adding-commenting-support as to fixing/supporting commenting
In reply to: Delete Selected not workingThis is claimed as fixed, though I am using the most updated version of buddypress and still having the same problem. Do I have to pull from the trunk to get the truly most updated version or do y’all push it to the wordpress plugin repo?
To answer my own question, first:
//Get friends Loop do_action( 'bp_before_activity_loop' ); if ( bp_has_activities( bp_ajax_querystring( 'activity' )."&scope=friends") ) : $friends_activites = $activities_template->activities; endif; do_action( 'bp_after_activity_loop' ); //Get personal Loop do_action( 'bp_before_activity_loop' ); if ( bp_has_activities( bp_ajax_querystring( 'activity' )."&scope=just-me") ) : $personal_activites = $activities_template->activities; endif; do_action( 'bp_after_activity_loop' );Then:
$activities_template->activities = array_merge($personal_activites,$friends_activites);Then loop:
<?php while ( bp_activities() ) : bp_the_activity(); ?> <?php bp_get_template_part( 'activity/entry' ); ?> <?php endwhile; ?>There might be a little I’m leaving out. If you view my profile and look at some of my forum activity you can probably find the whole code snippet. Too tired to post all of it.
In reply to: Activity stream queries as objectsThe following works for me.
do_action( 'bp_before_activity_loop' ); if ( bp_has_activities( bp_ajax_querystring( 'activity' )."&scope=groups") ) : $group_activites = $activities_template->activities; endif; do_action( 'bp_after_activity_loop' );I know you probably figured it out at this point, but I’m putting the answer here in case somebody else stumbles upon it.
I believe the above doesn’t work correctly because I am adding the new content as a subnav which by default tried to inherit the parent template (correct me if I’m wrong).
Here is what I came up with (this all goes in functions.php), it still needs fine tuning and testing (for example I broke pagination and commenting):
function my_test_setup_nav() { global $bp; $parent_slug = 'wall'; $child_slug = 'all'; //name, slug, screen, position, default subnav bp_core_new_nav_item( array( 'name' => __( 'test' ), 'slug' => $parent_slug, 'screen_function' => 'my_profile_page_function_to_show_screen', 'position' => 40, 'default_subnav_slug' => 'test_sub' ) ); } function my_profile_page_function_to_show_screen() { //add title and content here - last is to call the members plugin.php template add_action( 'bp_template_title', 'my_profile_page_function_to_show_screen_title' ); add_action( 'bp_template_content', 'my_profile_page_function_to_show_screen_content' ); bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) ); } function my_profile_page_function_to_show_screen_title() { echo 'something'; } function my_profile_page_function_to_show_screen_content() { global $activities_template; $personal_activites = array(); $friends_activites = array(); $group_activites = array(); //Get friends Loop do_action( 'bp_before_activity_loop' ); if ( bp_has_activities( bp_ajax_querystring( 'activity' )."&scope=friends") ) : $friends_activites = $activities_template->activities; endif; do_action( 'bp_after_activity_loop' ); //Get personal Loop do_action( 'bp_before_activity_loop' ); if ( bp_has_activities( bp_ajax_querystring( 'activity' )."&scope=just-me") ) : $personal_activites = $activities_template->activities; endif; do_action( 'bp_after_activity_loop' ); //Get groups Loop do_action( 'bp_before_activity_loop' ); if ( bp_has_activities( bp_ajax_querystring( 'activity' )."&scope=groups") ) : $group_activites = $activities_template->activities; endif; do_action( 'bp_after_activity_loop' ); do_action( 'bp_before_member_activity_post_form' ); bp_get_template_part( 'activity/post-form' ); do_action( 'bp_after_member_activity_post_form' ); $activities_template->activities = array_merge($personal_activites,$group_activites,$friends_activites); quickSort( $activities_template->activities ); ?> <?php do_action( 'bp_before_activity_loop' ); ?> <?php /* Show pagination if JS is not enabled, since the "Load More" link will do nothing */ ?> <noscript> <div class="pagination"> <div class="pag-count"><?php bp_activity_pagination_count(); ?></div> <div class="pagination-links"><?php bp_activity_pagination_links(); ?></div> </div> </noscript> <?php if ( empty( $_POST['page'] ) ) : ?> <ul id="activity-stream" class="activity-list item-list"> <?php endif; ?> <?php while ( bp_activities() ) : bp_the_activity(); ?> <?php bp_get_template_part( 'activity/entry' ); ?> <?php endwhile; ?> <?php if ( bp_activity_has_more_items() ) : ?> <li class="load-more"> <a href="#more"><?php _e( 'Load More', 'buddypress' ); ?></a> </li> <?php endif; ?> <?php if ( empty( $_POST['page'] ) ) : ?> </ul> <?php endif; ?> <?php do_action( 'bp_after_activity_loop' ); ?> <form action="" name="activity-loop-form" id="activity-loop-form" method="post"> <?php wp_nonce_field( 'activity_filter', '_wpnonce_activity_filter' ); ?> </form> <?php } add_action( 'bp_setup_nav', 'my_test_setup_nav' ); // Non-recurive Quicksort for an array of Person objects // adapted from http://www.algorithmist.com/index.php/Quicksort_non-recursive.php function quickSort( &$array ) { $cur = 1; $stack[1]['l'] = 0; $stack[1]['r'] = count($array)-1; do{ $l = $stack[$cur]['l']; $r = $stack[$cur]['r']; $cur--; do{ $i = $l; $j = $r; $tmp = $array[(int)( ($l+$r)/2 )]; // partion the array in two parts. // left from $tmp are with smaller values, // right from $tmp are with bigger ones do{ while( strtotime($array[$i]->date_recorded) > strtotime($tmp->date_recorded) ) $i++; while( strtotime($tmp->date_recorded) > strtotime($array[$j]->date_recorded) ) $j--; // swap elements from the two sides if( $i <= $j){ $w = $array[$i]; $array[$i] = $array[$j]; $array[$j] = $w; $i++; $j--; } }while( $i <= $j ); if( $i < $r ){ $cur++; $stack[$cur]['l'] = $i; $stack[$cur]['r'] = $r; } $r = $j; }while( $l < $r ); }while( $cur != 0 ); }I’m sure there is a more elegant and seamless way to do it, and I will try to figure out exactly what that is. I’ll probably end up making templates for this to try and have cleaner code and stop the ajax bugs I created.
But for now, congratulations, you now have an aggregate news feed.
Buddypress Wall sort of works, but it is riddled with bugs and the developer seems to be mia. That is to say, I don’t mean to knock the plugin; it is a good plugin but needs some bug fixes is all.
In reply to: BP Direct Menus – Adding notificationsAwesome, a post that isn’t years old that I may actually be able to help!
In functions.php add the following function:
function cg_current_user_notification_count() { $notifications = bp_core_get_notifications_for_user(bp_loggedin_user_id(), 'object'); $count = !empty($notifications) ? count($notifications) : 0; return $count; }In frontend-noajax.inc.php (you can find this in plugins/bp-direct-menus/inc) add the following code around line 150 (near where all the counts are initialized):
$notifcount = cg_current_user_notification_count(); $item->title = str_ireplace("%notificationcount%", $notifcount, $item->title); $item->title = str_ireplace("%(notificationcount)%", ($notifcount > 0) ? '('.$notifcount.')' : '', $item->title);Hope that helps you, or if you already figured it out, helps somebody else.
Cheers,
GabeIn reply to: How can I edit the html of navigation tabs?I ended up just copying the function and renaming it and using that. but of course the code is not pasting… So i’ll just point you where I went:
http://phpxref.ftwr.co.uk/buddypress/nav.html?_functions/index.html
Line 840
Hope this helps someone.
Every post I look at seems to be ages old, so hopefully this forum is not dead. I shall take it upon myself to revitalize posting actually useful things.