CB Activty filtering by asset

3 years 1 month ago #323993 by activha
CB Activty filtering by asset was created by activha
Hello

First of all congrats for all the job done on CB Activity ! I have noticed the progress on the uses that we have ;-)

I have a question regarding activities created in a cb activity module where the activity asset is specific to the page it was created on.

This works fine now, for instance : activ-ha.com/c/83-hotels/4221-test

Now the first activity also appears in the main timeline which is great.

However, there is no indication on this activity that it is linked to this asset.

So what can we use to have a specific link to the page it was created on ?

We use this to integrate the module
{module id="1445" activity_asset=<?php echo '"hotspot.' .$this->hotspot->id.'%"'; ?> fixhtml="false" style="division" moduleclass_sfx="cercle"}

Maybe is it possible to automatically add a link to the page for each created activity, but how ?
Can I add it through the params also ?

Please Log in to join the conversation.

3 years 1 month ago #323995 by krileon
Replied by krileon on topic CB Activty filtering by asset
You're using a custom asset so you'd need to implement custom template code for parsing that asset into whatever it's supposed to be. The template files in the below location handle preparing source objects, determining access, and parsing the display of all core activity.

/components/com_comprofiler/plugin/user/plug_cbactivity/templates/default/core

You can add to those files in a custom CB Activity template. Simply create "custom" folder in the templates folder. Next copy the "core" folder from default to "custom". Now in CB Activity select "custom" as the template. You can now freely modify the core parsing to add your own. Note you will want to DIFF these against the defaults when a new release is made encase fixes have been applied.

Will be reviewing how to better handle this in a future release, but for now it's either through template files or through code so you could use CB Auto Actions to parse the activity instead, but that's a bit more complicated. In a future release I want to figure out some sort of management page in backend where you can supply necessary PHP, SQL, or something of the sort for parsing custom activity assets.


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 years 1 month ago #323997 by activha
Replied by activha on topic CB Activty filtering by asset
I think it could be better to use an auto action in order to limit modifying the core files. That's the way I went on all other plugins and I must admit that it's much safer ;-)

Could you tell me how to do it with an auto action ?

Please Log in to join the conversation.

3 years 1 month ago #324002 by krileon
Replied by krileon on topic CB Activty filtering by asset
For custom source parsing you'd use the activity_onAssetSource trigger. Source parsing lets CB Activity know what object is in relation to the activity. So for example GJ uses it to tell CB Activity we've a group object as the source for group activity. Example of its usage as follows.

Global
Triggers: activity_onAssetSource
Type: Code
User: Automatic
Access: Everybody
Conditions
Field: Custom > Value
Custom Value: [var1]
Operator: Is REGEX
Value: /hotspot\.\d+/
Action
Method: PHP
Code:
$variables['var2'] = SOURCE_OBJECT_HERE;
Parameters
References: Variable 2

You'll need to write the necessary PHP and set var2 to it. I've no idea what that might be for whatever your hotspots are, but you'd replace SOURCE_OBJECT_HERE with that source object. This is typically done by pulling the id from the asset using REGEXP then preparing an object from that. This has the benefit of all CB Activity API when calling the source API it knows the object already. That includes the activity_onAfterCreateStreamActivity trigger where var2 is the source object. That triggers variables are as follows.

$_PLUGINS->trigger( 'activity_onAssetSource', array( $asset, &$source ) );

The above isn't necessary for custom activity display parsing, but I'm just describing the process that CB GroupJive goes through.

As for display parsing you'd use the activity_onDisplayStreamActivity trigger as its name suggests. Same concept as above. We need to modify the data by references. Example as follows.

Global
Triggers: activity_onDisplayStreamActivity
Type: Code
User: Automatic
Access: Everybody
Conditions
Field: Custom > Value
Custom Value: [var1_asset]
Operator: Is REGEX
Value: /hotspot\.\d+/
Action
Method: PHP
Code:
$variables['var4'] = 'ACTIVITY MESSAGE HERE';
Parameters
References: Variable 2, Variable 4, Variable 5

Variables 2 and 4 are the activity title and message. If you need to insert custom HTML content use variable 5. This triggers variables are as follows.

$_PLUGINS->trigger( 'activity_onDisplayStreamActivity', array( &$row, &$title, &$date, &$message, &$insert, &$footer, &$menu, $stream, $output ) );

If you implemented the source parsing then you can use $variables->source() to get your hotspot object otherwise you'll have to add the code at this time in your display parsing 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.

Moderators: beatnantkrileon
Time to create page: 1.826 seconds

Facebook Twitter LinkedIn