[SOLVED] CB Activity

2 years 2 months ago #327944 by activha
Replied by activha on topic CB Activity
OK I got this correctly, but is there a way to override the title AND the name/avatar as shown by CB instead of recoding them ?

Please Log in to join the conversation.

2 years 2 months ago #327946 by krileon
Replied by krileon on topic CB Activity
There's no functionality to override the name/avatar. What are you trying to do exactly? Sorry, I still don't understand what look you're trying to achieve 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.

2 years 2 months ago #327948 by activha
Replied by activha on topic CB Activity
Have a look at the link I provide a couple of posts ago, the full header is displayed under the message with name/avatar/title

Please Log in to join the conversation.

2 years 2 months ago - 2 years 2 months ago #327954 by krileon
Replied by krileon on topic CB Activity
Oh, I see. You want content shown before the activity header. The best way to do that is act on the stream trigger and not the activity display trigger. Specifically activity_onBeforeDisplayActivityStream. Directly returning HTML in a Code action will insert it to the top of the stream. Its variables are as follows.

$_PLUGINS->trigger( 'activity_onBeforeDisplayActivityStream', array( &$rows, &$pageNav, &$searching, $viewer, &$stream, $output ) );

Below example for inserting HTML at the top.

Global
Triggers: activity_onBeforeDisplayActivityStream
Type: Code
User: Automatic
Access: Everybody
Action
Method: HTML
Code:
Hello!
Output
Display: return

Now lets take this a step further and output data from the first activity entry.

Global
Triggers: activity_onBeforeDisplayActivityStream
Type: Code
User: Automatic
Access: Everybody
Action
Method: PHP
Code:
echo array_values( $variables['var1'] )[0]->get( 'message' );
Output
Display: return

That will output the first message in the array. Now lets make sure there's activity to display AND that we're only looking at 1 filtered activity entry.

Global
Triggers: activity_onBeforeDisplayActivityStream
Type: Code
User: Automatic
Access: Everybody
Conditions
Field: Custom > Code
Custom Code:
return ( $variables['var5']->getInt( 'id' ) && $variables['var1'] ? 1 : 0 );
Operator: Equal To
Value: 1
Action
Method: PHP
Code:
$activity = array_values( $variables['var1'] )[0];

echo $activity->get( 'message' );
Output
Display: return

Now you can insert whatever you want at the top of directly accessed activity entries and still have access to that activity entries data.


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.

2 years 2 months ago - 2 years 2 months ago #327957 by activha
Replied by activha on topic CB Activity
That's really nice to have a way to display things above a single activity page, love this :-)

However I cannot use as is because the message is displayed as a string, without all the html chosen by the user (theme, actions, etc) and it would be very difficult to reproduce all cases to have the same display as in the main stream, with only the header under the message/content.

In fact I would have to write all the code from container file in php to reproduce the message with html, and to find a way to remove it from the display of the normal output.
That's a bit more complicated than a simple template override ?

Regarding CB Activity template, do you mean that I won't be able to use them with CB 6 and change container php file ?

Also for the condition it seems like it outputs an error : Call to a member function getInt() on bool

Please Log in to join the conversation.

2 years 2 months ago #327958 by krileon
Replied by krileon on topic CB Activity
Ok, maybe we'll try a CSS approach then. Give the below a try to turn it into a flexbox column and change the order of the activity body div.

.cb_template .cbActivity .activityContainer {
	display: flex !important;
}

.cb_template .cbActivity .activityContainer > div {
	order: 1;
}

.cb_template .cbActivity .activityContainer > .activityContainerContent {
	order: 0;
}

That'll turn the container into a flexbox column, set all the child divs to ordering 1, then set the content div (which contains the message) to ordering 0. This seams to work in my tests on your site. All that's left is making sure it only displays if there's only 1 activity entry, which my above auto action can do. Now you don't need to touch any of the template files so it'll be easier to maintain. This should also work fine on CB Activity 6.0.0 as in 6.0.0 the activity container is already a flexbox.

Also for the condition it seems like it outputs an error : Call to a member function getInt() on bool

Oops, forgot that trigger is changed in 6.0.0 you need to use var5 not var3. Have edited my post.


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

Facebook Twitter LinkedIn