Skip to Content Skip to Menu

CB auto action: display fields outside of joomla

  • krileon
  • krileon
  • ONLINE
  • Posts: 48534
  • Thanks: 8290
  • Karma: 1445
4 years 7 months ago #317318 by krileon

with [cb_marketevents] being a GJ event id.
Can I get directly the corresponding GJ event title in the above json without going with a SQL request as it's CB part and how ?

You only stored the event id so no you can't without doing a query to get the title.

For other joomla components, if I want to use CB API and auto actions to get DB table values, I guess that I have to go through a mySQL standard request in the PHP code ? or can I use the query auto actions to output something also in raw or json format ?

As it's PHP you can do whatever PHP code you need to do. Then just be sure to return an array or object in your code with the latest CB Auto Actions build and it'll serialize to JSON for you. A query action only ever outputs a string result of the first row and column so it won't really work unless you handle creating a JSON string in the query. Have added a feature ticket to see if I can make it a little smarter since CB Auto Actions can handle array and object output now.

forge.joomlapolis.com/issues/7890

That feature is a bit more complicated so that won't be something I can push soon.


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
4 years 7 months ago - 4 years 7 months ago #317319 by activha
That was quick but just got an error on the installer ;-)
Code:
Exception Type: Error File: /var/www/html/components/com_comprofiler/plugin/user/plug_cbautoactions/install.cbautoactions.php Line: 243 Message: Class 'CB\Plugin\AutoActions\SystemActions' not found

Maybe just an standard server error from our side, it reinstalled very well at third trial; sorry ...

You only stored the event id so no you can't without doing a query to get the title.


So I may just add a second CB query field to store the title depending on the [cb_marketevents] first query field ?
Is this that simple ?
Last edit: 4 years 7 months ago by activha.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48534
  • Thanks: 8290
  • Karma: 1445
4 years 7 months ago #317322 by krileon

Maybe just an standard server error from our side, it reinstalled very well at third trial; sorry ...

It's because this release stopped duplicating the library files. Our old library usage copied the plugin library files to a main library folder for the autoloader to pick up. CB Auto Actions now just extends the auto loader instead of making a copy. This will cause first install to possible fail if CB Auto Actions is already loaded before installing. Second install will clear it up fine.

So I may just add a second CB query field to store the title depending on the [cb_marketevents] first query field ?
Is this that simple ?

I suppose you could add a query field for that yes. I'd just do it in the PHP though. You've access to CBs API including CBs super global database object. Example as follows.

Code:
global $_CB_database; $_CB_database->setQuery( "SELECT `name` FROM `#__groupjive_groups` WHERE `id` = " . (int) '[cb_marketevents]' ); $groupName = $_CB_database->loadResult();


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
4 years 7 months ago #317323 by activha
Absolutely perfect !!

Would the CB API database also access any other joomla data in the tables or is it limited to CB ??
The following user(s) said Thank You: krileon

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48534
  • Thanks: 8290
  • Karma: 1445
4 years 7 months ago #317325 by krileon
You've complete access to Joomla and CB. So you can call Joomla API if you wanted. You can query any database table within your Joomla database using the super global provided above as well. Just be careful with how you pass data to the database or you could end up with SQL injection. Notice in my example I cast the substitution to an integer. Don't allow raw substitution values or anything the user can provide (e.g. from GET, POST, or fields) to reach the database unfiltered.


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.
The following user(s) said Thank You: activha

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

  • activha
  • activha
  • ONLINE
  • Posts: 2334
  • Thanks: 117
  • Karma: 13
4 years 7 months ago #317827 by activha
Coming back on this I have some difficulties getting substitutions to work like this :
Code:
$_CB_database->setQuery( "SELECT * FROM `#__groupjive_plugin_events` WHERE `id` = " . (int) '[cb_marketevents]' ); $event = $_CB_database->loadAssoc(); $eventname = $event['title'] . ': [cb:if user="' . $event['user_id'] . '" usergroup includes "18"][cb:userdata field="cb_marketing_multiplier" user="' . $event['user_id'] . '" /] €[cb:else]2 €[/cb:else][/cb:if]'; return array( 'username' => '[username]', 'user_id' => '[user_id]', 'campagne_id' => '[cb_marketevents]', 'campagne_title' => $eventname);

While this works fine
Code:
//$_CB_database->setQuery( "SELECT `title` FROM `#__groupjive_plugin_events` WHERE `id` = " . (int) '[cb_marketevents]' ); //$eventName = $_CB_database->loadResult(); //return array( 'username' => '[username]', 'user_id' => '[user_id]', 'campagne_id' => '[cb_marketevents]', 'campagne_title' => $eventName);

It seems like
Code:
[cb:if user="' . $event['user_id'] . '" usergroup includes "18"][cb:userdata field="cb_marketing_multiplier" user="' . $event['user_id'] . '" /]
is not substituted

Mind to tell if I made a mistake somewhere ?
$row loads all correct data and user group is correct also

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

Moderators: beatnantkrileon
Powered by Kunena Forum