Skip to Content Skip to Menu

CB Activity new use for spots display

  • krileon
  • krileon
  • ONLINE
  • Posts: 48536
  • Thanks: 8290
  • Karma: 1445
2 years 11 months ago #327210 by krileon
Replied by krileon on topic CB Activity new use for spots display
Ok, latest build release now supports usage of $action in your Code usages. To run substitutions you'd use the below for example.

Method: PHP
Code:
Code:
return $action->string( $user, 'Hello [username] !' );

This should work inside an included PHP file as well.


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 or Create an account to join the conversation.

  • activha
  • activha
  • ONLINE
  • Posts: 2334
  • Thanks: 117
  • Karma: 13
2 years 11 months ago #327211 by activha
Replied by activha on topic CB Activity new use for spots display
Ok ! Thanks for the onDisplayStreamActivity :-)
That's much easier with the correct trigger !

Regarding conditioning the auto action I'll try to explain better :

- in the post area a user can choose an action which has an id and is stored in the params of a single activity.
- selecting a specific id should trigger the display of a CB field in the post area (ajax ?)
- in a CB auto action, I'd like to condition the action of the auto action to the action of the activity. Say if activity action is #11, we execute such code or such auto action

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48536
  • Thanks: 8290
  • Karma: 1445
2 years 11 months ago #327212 by krileon
Replied by krileon on topic CB Activity new use for spots display

- in the post area a user can choose an action which has an id and is stored in the params of a single activity.
- selecting a specific id should trigger the display of a CB field in the post area (ajax ?)
- in a CB auto action, I'd like to condition the action of the auto action to the action of the activity. Say if activity action is #11, we execute such code or such auto action

You can't do that with PHP unless you're dealing with the saving part of it. The act of selecting an action never touches the server. It's just JavaScript. So you need to add custom JavaScript to display whatever you're wanting when someone selects an activity action from the dropdown.


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 or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48536
  • Thanks: 8290
  • Karma: 1445
2 years 11 months ago #327213 by krileon
Replied by krileon on topic CB Activity new use for spots display
I do not recommend trying to make something dependent on the features that already exist in CB Activity. What you're asking for is too specific for that. As suggested below you should implement your own button with its own inputs and save behavior to fully implement exactly what you're wanting.

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

Trying to force Actions, Locations, etc.. to all be dependent on one another just isn't going to work well and ultimately will be a cobbled together implementation that's going to fall a part in a future CB Activity release because those features will change over time while your custom implementation will be immune to all of that.


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 or Create an account to join the conversation.

  • activha
  • activha
  • ONLINE
  • Posts: 2334
  • Thanks: 117
  • Karma: 13
2 years 11 months ago #327215 by activha
Replied by activha on topic CB Activity new use for spots display

As suggested below you should implement your own button with its own inputs and save behavior to fully implement exactly what you're wanting.


Yes I agree with you... but I don't have the coding skills to write such a plugin with DB and all, and that's why I was trying workaround by assembling parts :-(

But of course I understand what you say

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48536
  • Thanks: 8290
  • Karma: 1445
2 years 11 months ago - 2 years 11 months ago #327216 by krileon
Replied by krileon on topic CB Activity new use for spots display
Below is a fully functioning example of how to add, save, and display a custom feature button during activity create entirely from CB Auto Actions.

Add Activity Feature
Global
Triggers: activity_onDisplayStreamActivityNew
Type: Code
User: Automatic
Access: Everybody
Action
Action 1
Method: PHP
Code:
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'; // CODE TO RENDER NEW FEATURE BUTTON $variables['var1']['left'][] = '<button type="button" class="btn btn-light btn-sm border streamToggle ' . htmlspecialchars( $buttonName ) . '" data-cbactivity-toggle-target=".' . htmlspecialchars( $buttonTarget ) . '" data-cbactivity-toggle-active-classes="btn-info" data-cbactivity-toggle-inactive-classes="btn-light border" 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 ); $action->substitutions( $substitutions );
Action 2
Method: HTML
Code:
Code:
<div class="border-top d-flex cb_form_line streamItemInputGroup [input_class] hidden"> <div class="d-none d-sm-block col-form-label flex-shrink-1 p-2 border-right font-weight-bold streamItemInputGroupLabel">[input_label]</div> <div class="flex-grow-1 streamItemInputGroupInput"> <input type="text" name="[input_name]" value="" class="form-control shadow-none border-0 w-100 streamInput" placeholder="[input_placeholder]"> </div> </div>
Output
Display: return
Parameters
Reference Variables: Variable 1

With the above the first action is the PHP. This I've setup with some configuration to ease implementing this. You can adjust those configuration variables to change how the button and its input displays. The second action renders the actual input. The old scaffolding required here really is the top most streamItemInputGroup div. The rest can be replaced with whatever input behavior you need.

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

The above is where you'd handle whatever storage behavior you need. For simplicity sake we're just saving it as a string into the activity entries parameter storage. You could use a custom database here if you wanted, but if you do I suggest doing that on activity_onAfterCreateStreamActivity since that'll let all the validation complete and the activity to exist since you'll probably need the newly created activity id. Note that it's storing to "custom" this needs to match whatever you set $inputName in the first auto action.

Display Activity Feature
Global
Triggers: activity_onDisplayStreamActivity
Type: Code
User: Automatic
Access: Everybody
Action
Method: HTML
Code:
Code:
[var1_params_custom]
Output
Display: Silent
Layout:
Code:
$variables['var5'] = $variables['var5'] . $content;
Method: PHP
Parameters
Reference Variables: Variable 5

The above substitutes in the custom parameter for display. Here you can just use whatever HTML you like. The Layout parameter is letting us control where we want this displayed. The above is using the $insert usage in CB Activity which lets us insert something directly below an activity message. If you were to use custom storage behavior then this would probably be a PHP action to query for and display whatever you're needing to display. Note again that "custom" must match whatever $inputName is set to.

I understand this maybe difficult, but if this is a critical feature of your site it maybe the 1 thing worth considering finding a PHP developer to help with. Given what you're wanting they'll need to know PHP, JS, and SQL. They do not need to know CB or CB Auto Actions as the above will give them what they need to know to add this. I hope the above can at least help get you started.

Note the above has been fully tested on 5.0.0+build.2021.10.26.14.06.02.ab259c116 (Latest) and confirmed working. You should see a new heart button when creating new activity.


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.
Last edit: 2 years 11 months ago by krileon.
The following user(s) said Thank You: activha

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum