Skip to Content Skip to Menu

🌲 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 1 week ago - 8 months 1 week ago #337843 by activha
Replied by activha on topic CB Gallery autoaction to create an item

You can also just directly insert the privacy rule into the database as well if you wanted

Excellent idea ! :-)

there might be an error happening in the code somewhere.

it's exactly the same code so apart of the user id which may be the issue, there is no reason that it works with exactly the same triggers on the website and not with the same triggers with postman for instance.

if I want to get the user id is it [var1_user_id] instead of automatic on the website ? is that not altered by chaining the autoactions ? do I have to pass var1 as reference ? knowing that we make an include for the php file ?

Once again I don't ask for debugging, just to figure out how it's working as it's very difficult to find out 
 
Last edit: 8 months 1 week ago by activha.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
8 months 1 week ago #337847 by krileon
Replied by krileon on topic CB Gallery autoaction to create an item
If you're chaining auto actions you'll likely want to leave User as Automatic.

Once again I don't ask for debugging, just to figure out how it's working as it's very difficult to find out

That's exactly what debugging means. I will review adding error output to raw access (e.g. &format=raw) by throwing a error HTTP header with the error message. That should make it easier to find bugs in code.


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 1 week ago - 8 months 1 week ago #337848 by activha
Replied by activha on topic CB Gallery autoaction to create an item
Ok so in the meantime I'll add the other autoaction code directly in the first one after the store

This works fine like this :-)

Just another question : how can I add the new item in a folder ?

I mean that I'd like all users to have a default folder named External uploads used by my api for instance.

So how would I create one if not exists or use one if exists ? It seems like folder are got by id so I've no real idea of how to achieve this.
Last edit: 8 months 1 week ago by activha.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
8 months 1 week ago #337856 by krileon
Replied by krileon on topic CB Gallery autoaction to create an item

Just another question : how can I add the new item in a folder ?

I mean that I'd like all users to have a default folder named External uploads used by my api for instance.

So how would I create one if not exists or use one if exists ? It seems like folder are got by id so I've no real idea of how to achieve this.

Either know the folder id in advance and set it or you'll need to create a folder using the folder class object, which is as follows.
Code:
$folder = new \CB\Plugin\Gallery\Table\FolderTable();

If you want everyone's files to be uploaded to the same folder you can do something like the below.
Code:
$folder = new \CB\Plugin\Gallery\Table\FolderTable(); $folder->load( [ 'asset' => 'profile.USER_ID_HERE', 'title' => 'Uploads' ] ); if ( ! $folder->getInt( 'id', 0 ) ) { $folder->set( 'user_id', USER_ID_HERE ); $folder->set( 'asset', 'profile.USER_ID_HERE' ); $folder->set( 'title', 'Uploads' ); $folder->set( 'published', 1 ); $folder->store(); } $item->set( 'folder', $folder->getInt( 'id', 0 ) );

That would see if a folder exists with a title of Uploads for their profile gallery and if it doesn't it will create one. It then sets it into the item.


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.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
8 months 1 week ago #337862 by krileon
Replied by krileon on topic CB Gallery autoaction to create an item
Ok, latest CB Auto Actions build release now supports error handling for &format=raw accessed auto actions. If there's any errors logged (be sure to enable Debug in your auto action) it will throw a 500 response code. If Joomla debug mode is enabled it will include any errors logged as a JSON array in the response body. This should allow you to debug where things might be failing assuming CB Auto Action caught whatever error is happening.


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
  • OFFLINE
  • Posts: 2336
  • Thanks: 117
  • Karma: 13
8 months 1 week ago #337864 by activha
Replied by activha on topic CB Gallery autoaction to create an item
Works perfectly well now !

I was trying to set formData.append('name', `<a href="/profil/${external_userid}">${name_user}</a>`);
in order to link the name of the added file to the profile of the external user who contributes by uploading the file, but it seems like CB Gallery cleans it and I only get the  ${name_user}

Is there a solution to add a link in the name ?

It's tweaky because connected users are able to add files in the folder and I'd like to link their profie somehow. Any suggestion ?
I know that the owner can always rename it but that's only an indication of the profile who has contributed

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

Moderators: beatnantkrileon
Powered by Kunena Forum