Tagged: activity shortcode
Hi,
the load newest button appears only in activity pages. I mean if your shortcode is displayed in sidebar of activity page, button is displayed. But outside of activity page, the JS button doesn’t appear. How can I force the button to be displayed ? Do you have an idea of where in BP the activity page test is done ? Thanks…
Hi,
I am sorry for the delayed reply.The widget is not supposed to show load more button. if it is doing that, most probably some theme/css issue.
The widget is for listing activity with paginations.
The problem with load more is it works on the basis of filters/scopes and BuddyPress uses cookies to setup this scope/filter.
If you use load more button, It will give incorrect activities for listing since the activity widget filters and your activity directory filters can be different.
Hope that clarifies.
Hi,
actually I don’t talk about the LOAD MORE but the LOAD NEWEST button (top of the activity list). The LOAD MORE (bottom) is working well and I modified the filters in activity loop in order to have the right activities loading. The LOAD MORE button is always displayed, and the loaded activities are displayed by ajax (working well when clicked)
My problem is the LOAD NEWEST button which is not displayed until a new activity is saved (this is checked every 15s by an ajax call I think). The trick is that the ajax call only append in activity pages (activity page, members or group activity). If I put my activity shortcode in a widget inside an activity page, the LOAD NEWEST appears on top of your plugin, so it’s working well. But outside of these activty pages, it’s not.
So the goal is to find where in BP the test for “are we on activity page ?” is done, in order to load the js file too in my single page…
I hope I’m clear enough…Thanks
Hi,
Thank you for the clarification. The code for loading newest activity is part of bussypress.js(that comes with your theme or loaded via the theme compatibility).Here is the code section in that js file that does it.
/** Activity HeartBeat ************************************************/ // Set the interval and the namespace event if ( typeof wp !== 'undefined' && typeof wp.heartbeat !== 'undefined' && typeof BP_DTheme.pulse !== 'undefined' ) { wp.heartbeat.interval( Number( BP_DTheme.pulse ) ); jq.fn.extend({ 'heartbeat-send': function() { return this.bind( 'heartbeat-send.buddypress' ); } }); } // Set the last id to request after var first_item_recorded = 0; jq( document ).on( 'heartbeat-send.buddypress', function( e, data ) { first_item_recorded = 0; // First row is default latest activity id if ( jq( '#buddypress ul.activity-list li' ).first().prop( 'id' ) ) { // getting the timestamp timestamp = jq( '#buddypress ul.activity-list li' ).first().prop( 'class' ).match( /date-recorded-([0-9]+)/ ); if ( timestamp ) { first_item_recorded = timestamp[1]; } } if ( 0 === activity_last_recorded || Number( first_item_recorded ) > activity_last_recorded ) { activity_last_recorded = Number( first_item_recorded ); } data.bp_activity_last_recorded = activity_last_recorded; last_recorded_search = bp_get_querystring('s'); if ( last_recorded_search ) { data.bp_activity_last_recorded_search_terms = last_recorded_search; } }); // Increment newest_activities and activity_last_recorded if data has been returned jq( document ).on( 'heartbeat-tick', function( e, data ) { // Only proceed if we have newest activities if ( ! data.bp_activity_newest_activities ) { return; } newest_activities = data.bp_activity_newest_activities.activities + newest_activities; activity_last_recorded = Number( data.bp_activity_newest_activities.last_recorded ); if ( jq( '#buddypress ul.activity-list li' ).first().hasClass( 'load-newest' ) ) { return; } jq( '#buddypress ul.activity-list' ).prepend( '<li class="load-newest"><a href="#newest">' + BP_DTheme.newest + '</a></li>' ); }); });
Most probably the buddypress.js file is not getting loaded on your page where you have used the shortcode. Please check for that.
You must be logged in to reply to this topic.