CB Activity API usage update

3 months 3 weeks ago #336517 by krileon
Replied by krileon on topic CB Activity API usage update

I am using an API which is automatically proposing companies in the geographical area of the user.

Specifically companies or just places on a map? The new Location feature lets them directly navigate the area around them and select locations. It will geolocate the location properly as well. Example using the OSM map below.

All of the places details are stored to the activity entry (name, address, latitude, and longitude) for retrieval. You can use that information in a custom activity display template file to pull further business details if needed. You can make posts be required to provide a location as well.

The integration with CB Activity is fine because it allows to discuss around the company profile. For instance :

The custom activity generated for Hotspots entries would allow for that as well and avoid all this custom coding.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

3 months 3 weeks ago #336520 by activha
Replied by activha on topic CB Activity API usage update

Specifically companies or just places on a map?  


Specifically companies and their contacts as we get lots of details via the API. That's not achievable with Hotspots.
We geolocate automatically the user by IP or via its smartphone. Then the API proposes a list of companies and retrieve their detailed infos (marketing, financial datas, contacts emails, LinkedIn, etc)

The custom activity generated for Hotspots entries would allow for that as well and avoid all this custom coding. 

Yes I know, we had Hotspots before.
But it's not adapted to what we did. That's why I did all this coding on the last two years (but I'm not a coder at all ;-) )
it works fine on the production website on CB 5 but I cannot update it any longer unless I adapt it to CB 6

On the devel website with CB 6 and despite the modifications that you indicated, the custom code still does not function. I have lots of errors like Argument #3 ($var3) must be passed by reference, value given and our customized buttons do not show neither with the error Layout code failed. Error: Unclosed '{' on line 1

 

Please Log in to join the conversation.

3 months 3 weeks ago #336523 by krileon
Replied by krileon on topic CB Activity API usage update
There wasn't a drastic change here in regards to the triggers. Their giant list of variables were just moved into an array, because there were too many variables. So you need to adjust to use that array of variables. Below is a map of the variables that should make this pretty easy to make your changes.

OLD: activity_onDisplayStreamActivity
$_PLUGINS->trigger( 'activity_onDisplayStreamActivity', array( &$row, &$title, &$date, &$message, &$insert, &$footer, &$menu, $stream, $output ) )
NEW: activity_onDisplayActivity
HtmlHelper::getIntegrations( 'onDisplayActivity', [ &$rowStream, &$row, [
	'title'		=>	&$title,
	'caret'		=>	&$caret,
	'date'		=>	&$date,
	'message'	=>	&$message,
	'content'	=>	&$content,
	'media'		=>	&$media,
	'header'	=>	&$header,
	'footer'	=>	&$footer,
	'menu'		=>	&$menu,
	'compact'	=>	&$compact,
	'isDetails'	=>	false,
	'isNew'		=>	$isNew,
	'isRow'		=>	$isRow,
	'isModal'	=>	$isModal,
	'isInline'	=>	$isInline,
	'isSimple'	=>	$isSimple,
	'isEmbed'	=>	$isEmbed,
] ] );

MAP:
var1 -> var2
var2 -> var3 (substitution: var3_title)
var3 -> var3 (substitution: var3_date)
var4 -> var3 (substitution: var3_message)
var5 -> var3 (substitution: var3_content)
var6 -> var3 (substitution: var3_footer)
var7 -> var3 (substitution: var3_menu)
var8 -> var1
var9 -> removed

OLD: activity_onDisplayStreamActivityNew
$_PLUGINS->trigger( 'activity_onDisplayStreamActivityNew', array( &$buttons, $viewer, $stream, $output ) );
NEW: activity_onDisplayActivityStreamNew
HtmlHelper::getIntegrations( 'onDisplayActivityStreamNew', [ $rowStream, &$row, &$form ] );

MAP:
var1 -> var3 (substitution: var3_menu)
var2 -> removed
var3 -> var1
var4 -> removed

The triggers for activity save behavior are unchanged. It's primarily and almost exclusively the display triggers that have changed.

Will try to provide a working updated example as I did in your previous topic since it's only fair that I update my example.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

3 months 3 weeks ago #336527 by activha
Replied by activha on topic CB Activity API usage update
Thanks if you write an update that will be much needed.

I have also noticed that our two autoactions code for routing with onBuildRoute and onParseRoute did not work any longer neither :-(

Please Log in to join the conversation.

3 months 3 weeks ago #336528 by krileon
Replied by krileon on topic CB Activity API usage update
Ok, below is an updated example of the one provided in the following post.

www.joomlapolis.com/forum/255-developer-members-support/244490-cb-activity-new-use-for-spots-display?start=18#327216

Add Activity Feature
Global
Triggers: activity_onDisplayActivityStreamNew, activity_onDisplayActivityStreamEdit
Type: Code
User: Automatic
Access: Everybody
Action
Action 1
Method: PHP
Code:
// CODE TO CONFIGURE NEW FEATURE BUTTON

$buttonName				=	'streamInputCUSTOM';
$buttonTarget			=	'streamInputCUSTOMContainer';
$buttonDescription		=	'Check out this new custom button!';
$buttonIcon				=	'fa fa-heart';

$inputName				=	'custom';
$inputLabel				=	'LABEL';
$inputPlaceholder		=	'PLACEHOLDER';

$inputValue				=	$variables['var2']->getParams()->getString( $inputName, '' );

// CODE TO RENDER NEW FEATURE BUTTON

$variables['var3']['menu'][]		=	'<div class="streamCustom streamTooltip"' . \CB\Plugin\Activity\Helper\HtmlHelper::getSimpleTooltip( $buttonDescription ) . '>'
									.		'<button type="button" class="btn ' . ( ! $inputValue ? 'btn-light border' : 'btn-info' ) . ' streamToggle ' . htmlspecialchars( $buttonName ) . '" data-cbactivity-toggle-target=".' . htmlspecialchars( $buttonTarget ) . '" data-cbactivity-toggle-active-classes="btn-info" data-cbactivity-toggle-inactive-classes="btn-light border">'
									.			'<span class="' . htmlspecialchars( $buttonIcon ) . '"></span>'
									.		'</button>'
									.	'</div>';

$substitutions						=	$action->substitutions();
$substitutions['input_name']		=	htmlspecialchars( $inputName );
$substitutions['input_label']		=	$inputLabel;
$substitutions['input_placeholder']	=	htmlspecialchars( $inputPlaceholder );
$substitutions['input_class']		=	htmlspecialchars( $buttonTarget );
$substitutions['input_value']		=	htmlspecialchars( $inputValue );

$action->substitutions( $substitutions );
Action 2
Method: HTML
Code:
<div class="border-top d-flex streamItemInputGroup [input_class] [cb:if input_value!=""]streamToggledOpen[cb:else]hidden[/cb:else][/cb:if]">
	<div class="col-form-label flex-shrink-1 p-2 border-right font-weight-bold streamItemInputGroupLabel">
		[input_label]
	</div>
	<div class="position-relative flex-grow-1 streamItemInputGroupInput">
		<input type="text" name="[input_name]" value="[input_value]" class="form-control shadow-none border-0 h-100 w-100 streamInput" placeholder="[input_placeholder]" [cb:if input_value=""]disabled[/cb:if] />
	</div>
</div>
Output
Display: return
Parameters
Reference Variables: Variable 3

Save Activity Feature
Global
Triggers: activity_onBeforeUpdateStreamActivity, activity_onBeforeCreateStreamActivity
Type: Code
User: Automatic
Access: Everybody
Action
Method: PHP
Code:
$variables['var3']->getParams()->set( 'custom', $input->getString( 'custom', '' ) );
Parameters
Reference Variables: Variable 3

Display Activity Feature
Global
Triggers: activity_onDisplayActivity
Type: Code
User: Automatic
Access: Everybody
Action
Method: HTML
Code:
[var2_params_custom]
Output
Display: Silent
Layout:
$variables['var3']['content'] = $variables['var3']['content'] . $content;
Method: PHP

This updated usage will display a new menu button to toggle on the display of a new input field. It will then save it. It also works with activity edits now.

Note this has been tested as fully working. You should see a new button with a heart icon. Clicking it should toggle open a new input. Filling the input with text should save. The saved text should display in the activity post. When editing the post the button should be active, the input displayed, and contain the text you input.

You do not need to set Variable 3 as a reference for activity_onDisplayActivity since it's an inline array.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

3 months 3 weeks ago #336529 by krileon
Replied by krileon on topic CB Activity API usage update

I have also noticed that our two autoactions code for routing with onBuildRoute and onParseRoute did not work any longer neither

CB Activity has support for SEO URLs out of the box now. So shouldn't be necessary. Your custom routing might be conflicting with the built in routing behavior, but can't say for sure. Below is an SEO URL to a post on our demo site for example.

demo.cbdemosites.com/post/341

You might be able to override it by ensuring CB Auto Actions is ordered before CB Activity in CB > Plugin Management as that should give priority to CB Auto Actions for the routing trigger.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.534 seconds

Facebook Twitter LinkedIn