CB Activity API usage update

3 months 3 weeks ago #336481 by activha
CB Activity API usage update was created by activha
Thanks it installed correctly.

However I need some explanations about assigning a stream to my class of assets like activha.group.55.event.26.activation.11827

Should I only affect all these to a menu itemid ? for instance if I have a stream Menu 1926 with Ressource %activation.[user_id]% , does it mean that I should affect all my orphaned activities to this one ?

Also regarding the triggers :
Could you explain the correspondance between old ones and new ones ?

for instance what replaces :
activity_onDisplayStreamActivity
activity_onDisplayStreamActivitySave
activity_onDisplayStreamActivityEdit
activity_onDisplayStreamActivityNew
activity_onAfterCreateStreamActivity
activity_onAfterUpdateStreamActivity

I'm moving our dev install to CB 6
Thanks

Please Log in to join the conversation.

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

Should I only affect all these to a menu itemid ? for instance if I have a stream Menu 1926 with Ressource %activation.[user_id]% , does it mean that I should affect all my orphaned activities to this one ?

That's entirely up to you. If that's what stream those posts belong to then yes.

Also regarding the triggers :
Could you explain the correspondance between old ones and new ones ?

The updated triggers are all listed below with their variables.

www.joomlapolis.com/blog/kyle/19034-cb-activity-6-0-0-rc-1

You don't technically need to use triggers anymore for custom activity parsing. I'll be posting a blog on this later, but it can be done exclusively through template files so you can work directly with PHP. Examples can be found in the below files.

Activity Display
/components/com_comprofiler/plugin/user/plug_cbactivity/templates/default/activity/custom/example.php

Notification Display
/components/com_comprofiler/plugin/user/plug_cbactivity/templates/default/notifications/custom/example.php

Asset Access Check
/components/com_comprofiler/plugin/user/plug_cbactivity/templates/default/assets/access/example.php

Asset Context URL
/components/com_comprofiler/plugin/user/plug_cbactivity/templates/default/assets/context/example.php

Asset Grouping
/components/com_comprofiler/plugin/user/plug_cbactivity/templates/default/assets/group/example.php

Asset Source Objects
/components/com_comprofiler/plugin/user/plug_cbactivity/templates/default/assets/source/example.php

These all use what's called an Asset Path. The asset path is available under the Details tab when editing an activity or notification entry. So for example edit a post in CB Activity > Activity and you for example might have the following.

Asset: groupjive.group.500151.join
Asset Path: /groupjive/group/join.php

So if I wanted custom activity display behavior for this I'd create the below.

/components/com_comprofiler/plugin/user/plug_cbactivity/templates/default/activity/custom/groupjive/group/join.php


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 #336486 by activha
Replied by activha on topic CB Activity API usage update
OK understood
That'll be complicated and long to move all our code from autoactions to template files, so for now I'd like to stick with the autoactions.

However even with the latest CB autoaction build, there is no correspondances between the triggers.

I mean that I still have for instance activity_onDisplayStreamActivityNew instead of activity_onDisplayActivityStreamNew

And I don't have any outputs in the frontend.

for instance with this trigger I add buttons to the main box like here www.joomlapolis.com/forum/255-developer-members-support/244490-cb-activity-new-use-for-spots-display?start=18

Could you explain how to adapt it to the new CB Activity 6 ?

Thanks

Please Log in to join the conversation.

3 months 3 weeks ago - 3 months 3 weeks ago #336487 by krileon
Replied by krileon on topic CB Activity API usage update
Most of the trigger names are the same. Their variables however have changed. This is due to some of them just having way too many variables pertaining to their layouts. So those layout variables are now nested inside of an array. The variables can be found in my below blog post.

www.joomlapolis.com/blog/kyle/19034-cb-activity-6-0-0-rc-1

Example as follows.

activity_onDisplayActivity
var1 = $stream (this is the stream object the post belongs to)
var2 = $row (the activity post object iself)
var3 = $layout (the array of layout data)

So if you need to access the $title it's [var3_title]. If you need to access it from PHP in a code action then $variables should work I believe.

I forgot to update the trigger list in CB Auto Actions. Will update its list in a new build release. Below is an example of the renamed triggers.

activity_onDisplayStreamActivityNew = activity_onDisplayActivityStreamNew

Basically swap Stream and Activity. This was done because those variables changed drastically and would cause errors in other plugins and they're now specific to stream type.

I've also updated my blog post to expose the array data of $form so activity_onDisplayActivityStreamNew will be easier to understand. You'll notice there's a buttons array available in $form for inserting buttons. There's no left/right usage anymore. So for example you'd adjust the following.

FROM:
$variables['var1']['left']
TO:
$variables['var3']['buttons']

With CB 3.x we'll be moving to event objects with getter and setter functions. This will let us better control backwards compatibility in triggers to avoid trigger variable breaks like this, but for now it's unavoidable.


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 #336501 by activha
Replied by activha on topic CB Activity API usage update
OK thanks for the explanations. I think I'll have a few questions to begin to adapt everything to version 6

1)  can I still call [var2_params_activ] instead of old [var1_params_activ] to get the params data ? seems like I get an error 
Layout code failed. Error: Call to undefined method CB\Plugin\Activity\Table\ActivityTable::params()
on the following :

ACTION PHP

$url = 'index.php?option=com_comprofiler&view=pluginclass&plugin=cbactivity&action=activity&id=[var2_id]&Itemid=8125';
$com = !empty('[var2_params_event_title]')? \CBLib\Language\CBTxt::T( 'with_act', ' with ' ) . '[var2_params_event_title]':'';
$title ="[var2_params_activ]";
$reve_url = ('[var2_params_revechoice]'==62)?JRoute::_('index.php?option=com_comprofiler&view=pluginclass&plugin=cbgroupjive&action=groups&Itemid=8706&id=[var2_params_revechoice]', false):'pages/[var2_params_revechoice]';
$reve = !empty('[var2_params_revetitle]')? \CBLib\Language\CBTxt::T( 'for_the_association', ' for the association ' ) . '<a href="'.$reve_url.'" target="blank">[var2_params_revetitle]</a>':'';

$variables['var3']=\CBLib\Language\CBTxt::T( 'activating', 'has activated ' ) . '<a class="btn btn-outline-primary fw-bolder font-weight-bolder" href="'.JRoute::_($url , false).'">'. $title .'</a>'.$com.$reve;


LAYOUT RETURN PHP

$variables['var3'] = $content . $variables['var3'];
$loc = $variables['var2']->params()->get( 'location' );
if (isset($loc['address']) && $loc['address'] == '') echo '<div class="text-danger small">Ajoutez le lieu de cette activation !</div>';



2) Then, where can I find the new codes for the new buttons in this second autoaction ? 

What we had was :
ACTION PHP
// CODE TO CONFIGURE NEW FEATURE BUTTON

$buttonName = 'streamInputActiv';
$buttonTarget = 'streamInputActivContainer';
$buttonDescription = 'Faire une nouvelle activation';
$buttonIcon = 'fa-sharp fa-solid fa-plus fa-lg px-2';

$inputName = 'activ';
$inputLabel = 'QUI ?';
$inputPlaceholder = 'une société ? un nom ?';
$locationPlaceholder = 'quelle est l\'adresse de ton activation ?';

$variables['var3']['buttons'] = '<button type="button" class="btn btn-light btn-sm p-0 streamToggle ' . htmlspecialchars( $buttonName ) . '" data-cbactivity-toggle-target=".streamInputUploadContainer,.' . htmlspecialchars( $buttonTarget ) . '" data-cbactivity-toggle-active-classes="bg-info" data-cbactivity-toggle-inactive-classes="btn-light" data-cbtooltip-tooltip="' . htmlspecialchars( $buttonDescription ) . '" data-hascbtooltip="true" data-cbtooltip-position-my="bottom center" data-cbtooltip-position-at="top center" data-cbtooltip-classes="qtip-simple"><span class="' . htmlspecialchars( $buttonIcon ) . '"></span></button>';

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

$action->substitutions( $substitutions );

ACTION HTML
<div class="border-top d-flex cb_form_line streamItemInputGroup [input_class] hidden">
<div class="d-block col-form-label flex-shrink-1 p-2 font-weight-bold text-primary streamItemInputGroupLabel">
[input_label]
</div>
<div class="flex-grow-1 streamItemInputGroupInput">
<div class="typeahead__company">
<input id="company" name="activ" type="search" autocomplete="off" class="form-control shadow-none border-0 w-100 streamInput" placeholder="[input_placeholder]" data-curpage="1" />
<div id="company_res" class="company_res" hidden><div class="close_res">X</div>
<ul hidden>
</ul>
<div class="ac_arrow_box">
<div class="ac_arrow_button ac_arrow_button_left">
<div class="ac_arrow_left">
<i class="fa-sharp fa-solid fa-arrow-left fa-lg"></i>
</div>
</div>
<div class="ac_arrow_button ac_arrow_button_right">
<div class="ac_arrow_right">
<i class="fa-sharp fa-solid fa-arrow-right fa-lg"></i>
</div>
</div>
</div>
<div id="pager_box" class="pl-5 ps-5">
<div class="pager-left">
Page
</div>
<div class="pager-leftcenter">
</div>
<div class="pager-rightcenter">
de
</div>
<div class="pager-right">

</div>

</div>
</div>
</div>
</div>
</div>
<div class="d-flex cb_form_line streamItemInputGroup [input_class] hidden">
<div class="d-block col-form-label flex-shrink-1 p-2 font-weight-bold text-primary streamItemInputGroupLabel">
OU ?
</div>
<div class="flex-grow-1 streamItemInputGroupInput">
<div class="typeahead__location">
<input id="location" name="si_place" type="search" class="form-control shadow-none border-0 w-100 streamInput" placeholder="[input_location_placeholder]" autocomplete="off" />
<ul hidden>
</ul>
</div>
</div>
</div>
<div class="d-flex cb_form_line bg-light streamItemInputGroup [input_class] hidden">
<div class="flex-grow-1 streamItemInputGroupInput text-center text-muted ps-2 pl-2" id="previewloc">
</div>
</div>
<div class="d-flex cb_form_line bg-appli streamItemInputGroup small [input_class]">
<div class="flex-grow-1 px-1 py-0 small text-muted text-end text-right">
[cb:userfield field="cb_activ_cats" /]
</div>
</div>
<div class="d-flex flex-column cb_form_line bg-appli streamItemInputGroup [input_class]">
<div class="d-block col-form-label flex-shrink-1 pt-2 px-2 pb-0 font-weight-bold text-primary text-center streamItemInputGroupLabel">
EVENEMENT
</div>
<div class="flex-grow-1 pt-2 px-2 pb-0 text-center">
[cb:userfield field="cb_marketevents" /]
</div>
</div>


ACTION ONLINE CSS
.cb_template .activityContainerFooterRowLeft {
display: flex;
gap: 0.25rem;
flex-direction: row-reverse;
}
.cb_template .activityContainerContent {
display: flex;
/*gap: 0.25rem;*/
flex-direction: column-reverse;
background-color:#fafafa;
}
.cb_template .streamInputMessageContainer {
border-top: 1px solid #eee;
}
.cb_template .streamInputLocationContainer .streamItemInputGroupAddon {font-size:2rem;}
.cb_template .streamInputLocationContainerPlace > input,
.cb_template .streamInputLocationContainerAddress > input {
text-align:center; }
.cb_template .activityContainerNew .streamInputMessageContainer > textarea {
font-size: 1.5rem;
margin-top: 5px;
margin-bottom:5px;
text-align: center;
}



Thanks a lot

Please Log in to join the conversation.

3 months 3 weeks ago #336504 by krileon
Replied by krileon on topic CB Activity API usage update
You need to replace ->params() with ->getParams() in your layout code. As for your substitutions yes those will still work. This is a very messy way to have custom activity though. I recommend checking out the template based approach.

2) Then, where can I find the new codes for the new buttons in this second autoaction ?

I've listed all the triggers and their variables in my blog post. I exploded the $form array as well so you can see what it contains. Beyond that I don't know what you're asking.

You however aren't using the buttons array correctly. You're replacing the array with a string. You need to append to the array. So you need to use the following.
$variables['var3']['buttons'][] = 'BUTTON_HERE';


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.736 seconds

Facebook Twitter LinkedIn