Skip to Content Skip to Menu

CB auto action: display fields outside of joomla

  • activha
  • activha
  • ONLINE
  • Posts: 2334
  • Thanks: 117
  • Karma: 13
4 years 7 months ago #317309 by activha
Hello

We would like to display CB html fields with an auto action but outside of joomla in an iOS App.

How and what auto action could we use for this ?
The user is authenticated by joomla within the web view and has full access to all joomla data, but we have a native page on which we would like to display some CB fields (either raw or best with ajax edition possible)

Thanks for your idea

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 #317311 by krileon
Only way to interface native with Joomla in general is using API endpoints, which don't exist in Joomla. You can basically fake it with CB Auto Actions by calling a auto action URL from your native API. This will initialize and route through Joomla so you should have access to all of Joomla and CBs API. The problem will be the user object. It won't have a clue what user object you're trying to use so it'll just be a guest user object unless you include the user id in your request. Example as follows would execute an auto action (it must have Triggers set to None) with a specific user.

index.php?option=com_comprofiler&view=pluginclass&plugin=cbautoactions&action=action&actions=ACTION_ID&users=USER_ID

I'd recommend using a Code action with Method set to PHP then responding with a small JSON payload then convert that JSON into whatever display you're wanting in your native application. It's possible to just respond with HTML, but that kind of defeats the point of using a native application to reduce data load.


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 #317314 by activha
Thanks ! That's why we rely on CB, for its power :-)

What would you suggest for php code if we want to retrieve the user fields in json format ?

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 #317315 by krileon
You should be able to just use substitutions in your PHP. Example as follows.

Action
Method: PHP
Code:
Code:
return json_encode( array( 'username' => '[username]', 'name' => '[name]' ) );
Output
Display: exit

Be sure to add &format=json or &format=raw to your auto action URL so all it outputs is the JSON data. Will review adding a new output display parameter for JSON so it can goahead and set the header for you too.

forge.joomlapolis.com/issues/7889


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 #317316 by activha
I have two more questions.

Say that I have
Code:
return json_encode( array( 'username' => '[username]', 'id' => '[user_id]', 'campagne' => '[cb_marketevents]' ));

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 ?

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 ?

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 #317317 by krileon
Ok, latest build available now has just made this even easier. Once installed you'll be able to do the below for example.

Action
Method: PHP
Code:
Code:
return $user;
Output
Display: JSON

This would give you a JSON dump of the raw user object. The code action can now handle returning objects and arrays. They'll always be serialized to JSON during layout handling. Using my earlier example you'd have the below.

Action
Method: PHP
Code:
Code:
return array( 'username' => '[username]', 'name' => '[name]' );
Output
Display: JSON

You don't need to json encode manually and this output usage sets the header content type to JSON for you. I recommend the above approach so you only return the information you actually need instead of the entire user object.


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.

Moderators: beatnantkrileon
Powered by Kunena Forum