Create item in custom code

More
7 years 3 months ago #65724 by ilo
Hello,
After a submission form in frontend that create a first item, I want to create a second item automatically. I try to use your script that I found in the FAQ :
www.flexicontent.org/documentation/faq/7...-in-custom-code.html
I don't know exactly where I could insert this script (the best way), in the file form.php ? Or anywhere else ?
Thank you

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

More
7 years 3 months ago #65727 by micker
Replied by micker on topic Create item in custom code
you need to create a plugin and use onsubmit event to catch save event not ?

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

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

More
7 years 3 months ago - 7 years 3 months ago #65730 by ilo
Replied by ilo on topic Create item in custom code
I don't know if a new plugin is necessary, for the moment I just tried to execute the script in a new file, create_item.php, to test it with a joomla menu item of type external link, in order to create a new item, so with :

$item_ID = 0;
$data = 0;

and I have an error message :
Fatal error: Call to a member function getError() on null in /mysite/create_item.php on line 198

196 if ( !$item_model->store($data) )
197 {
198 $msg = 'Failed to create the new item: '. $model->getError();
199 JLog::add($msg);
200 echo $msg."<br/>";
201 }

What's wrong ? Is there something else to do ?
Last edit: 7 years 3 months ago by ilo. Reason: une erreur résolue mais une nouvelle

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

More
7 years 3 months ago - 7 years 3 months ago #65731 by ilo
Replied by ilo on topic Create item in custom code
Just an little question more, that can maybe explain the previous one; In the script, there is line 92 :
Code:
$data['custom']['field2'][1] = 'this value 1 of field 2';

What 'custom' is supposed to be ?
Last edit: 7 years 3 months ago by ilo.

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

More
7 years 3 months ago #65736 by ggppdk
Replied by ggppdk on topic Create item in custom code
Hello

You can duplicate plugin:
/plugins/flexicontent/flexinotify/flexinotify.php

and use event:
onAfterSaveItem

to do things,

but you cannot create an other item,
it will create a loop, because onAfterSaveItem will be triggered again

it is better to create a system plugin
and check if current URL is item saving URL

check current url has (e.g. backend URL)
&option=com_flexicontent&task=items.save


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.995 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline