Skip to Content Skip to Menu

🌟Discover the Joomla AI Plugin that wrote its own story! - CB Editor Assistant 1.1now for Joomla 3, 4 & 5!
✍️ 5-Day Free Trial, then 🎯 save up to 30% with our 🛍️ Intro Offer (First 50 users, ends Dec. 25th)
🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

CB Gallery autoaction to create an item

  • activha
  • activha
  • OFFLINE
  • Posts: 2336
  • Thanks: 117
  • Karma: 13
8 months 2 weeks ago #337759 by activha
Hello

I was wondering whether it is possible to create a gallery item externally and with which trigger ?

The idea would be to have an autoaction with direct access allowing a registered user to upload a gallery item from a widget displayed on outside websites.

We would identify the user by a token (CB field) 

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
8 months 2 weeks ago #337764 by krileon
Replied by krileon on topic CB Gallery autoaction to create an item
The CB Gallery auto action will let you create a new media entry, but it will only create link entries. It does not support uploads. You would have to code such a use case yourself using a Code action to deal with uploading the file.

You wouldn't use a trigger for this. You'd need to authenticate them like you would for any API endpoint and how you do that is up to you. Then you'd call the auto action URL directly. Since you'd be using a token field you could set User parameter to Custom then in the custom user PHP find the user based off that token and return either their user object or user id and that user would then be used for the auto action.


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
  • OFFLINE
  • Posts: 2336
  • Thanks: 117
  • Karma: 13
8 months 2 weeks ago #337766 by activha
Replied by activha on topic CB Gallery autoaction to create an item
Ok got it, I already have the proper code to authenticate against a token for retrieving the user id and logging in the user.

If I code uploading the file to this proper CB user folder for files, can I create a link entry with this path using the CB Gallery auto action ? meaning with a post variable for instance ?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
8 months 2 weeks ago #337768 by krileon
Replied by krileon on topic CB Gallery autoaction to create an item
If you send the file through with a proper file POST header you can just call CB Gallery API in a Code action and it'll handle the upload itself otherwise you can place the file in the appropriate folder that CB Gallery expects it to be in (see /images/comprofiler/cbgallery) then create a database entry with the relevant information about the file (either directly or by using CB Gallery API). Linking would not be the appropriate method for uploads.


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
  • OFFLINE
  • Posts: 2336
  • Thanks: 117
  • Karma: 13
8 months 2 weeks ago #337770 by activha
Replied by activha on topic CB Gallery autoaction to create an item
Could you tell me how to call the CB Gallery API in a code action ?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
8 months 2 weeks ago #337771 by krileon
Replied by krileon on topic CB Gallery autoaction to create an item
You'll need to work with gallery item table object. Specifically the below class.

/components/com_comprofiler/plugin/user/plug_cbgallery/library/Table/ItemTable.php

Example of how to initialize such object.
Code:
$item = new \CB\Plugin\Gallery\Table\ItemTable();

Review the class provided above for further usage information. It can process the upload automatically in ->store if you set the input data into _input and the files data into _files. Example as follows.
Code:
$item = new \CB\Plugin\Gallery\Table\ItemTable(); $item->set( '_input', $input ); $item->set( '_files', $input->getNamespaceRegistry( 'files' ) );

That would work with a standard HTML form. So you'll need to adjust it however necessary based off your usage. _files is specifically the PHP global $_FILES.


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.

Moderators: beatnantkrileon
Powered by Kunena Forum