Canceling saving of an item via onBeforeSaveField function

More
13 years 9 months ago #25250 by yaK2manD
I was an example.

Imagine I have a youtube link :


A user just fill in the link, and my script extract the id : lHTAV9H8yK4
the title, and the image (just the link).
I would like to store all these data in different fields (video_id, image, title, link)

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

More
13 years 9 months ago #25253 by micker
its simply create a texte field allow plugin to insert video example jw video
and use {youtube}prefix and {/youtube} suffix
extensions.joomla.org/extensions ... allery/812
regards

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
13 years 9 months ago #25280 by yaK2manD
It would be too simple ;)

The video could be a youtube video, or dailymotion, or ...

I have to execute a script in order to get all the video's information and fill other fields (extract the title to name the article, ...)

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

More
13 years 9 months ago #25307 by yaK2manD
I will use :

micker wrote: its simply create a texte field allow plugin to insert video example jw video
and use {youtube}prefix and {/youtube} suffix
extensions.joomla.org/extensions ... allery/812
regards


with a field own-made.

But I would like to know if it is possible to fill a field through another ?
Maybe in the form ?

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

More
13 years 9 months ago #25312 by ggppdk
Check this FAQ article, but note it is meant for developers:

Creating relation between fields:
www.flexicontent.org/documentati ... ields.html

Regards


-- 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 review. Thanks!

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

More
13 years 9 months ago #25649 by yaK2manD
Hi,

I have a problem with the BeforeSaveField.
How can I do in order to avoid saving article if my test failed ?

Because I have just a warning but article still saved.

I used :

ggppdk wrote: To pass an error notice to the frontend you could use:

Code:
if ($ihavefailed) { $jAp=& JFactory::getApplication(); $jAp->enqueueMessage("my error message", 'notice'); }



Thank you.

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

More
13 years 9 months ago #25655 by ggppdk
Saving fields is performed after item is saved so you can not cancel item saving inside this function by e.g. setting a message (with enqueueMessage) and then redirecting to some page e.g. refer (previous page)


We have another event that is triggered before saving item:
onBeforeSaveItem

and use inside a plugin of TYPE system or flexicontent:
Code:
function onBeforeSaveItem( & $item, $isnew ) { $post = JRequest::get('post'); //echo "<pre>"; $post; echo "</pre>"; exit; //$somethingbad = ... if ($somethingbad) { $app = &JFactory::getApplication(); $app->enqueueMessage( 'Some error detected', 'notice' ); return false; } return true; }


Also in backend items.php controller a fix for redirection after error during item saving:
replace:
Code:
$msg = ''; $link = 'index.php?option=com_flexicontent&view=item';
with
Code:
$msg = ''; $ctrl_task = FLEXI_J16GE ? 'task=items.edit' : 'controller=items&task=edit'; $link = 'index.php?option=com_flexicontent&'.$ctrl_task.'&cid='.(int) $model->get('id');

Regards


-- 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 review. Thanks!

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

More
13 years 9 months ago #25656 by yaK2manD
Thank you.

I have a last query :
In OnBeforeSaveField, I would like to delete entirely the item saved before.
Can I get the item id related to the field with $model->get('id') ?

Is there a way to delete (e.g. a function) an item properly ?



Thank you.

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

More
13 years 8 months ago #25697 by ggppdk
mmm, we could do this:

1. If any onBeforeSaveField() call returns false then the declare the saving process as failed
2. Then the saving controller task, will call delete TASK for new items and restore version TASK for existing items


-- 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 review. Thanks!

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

More
13 years 8 months ago #25709 by yaK2manD
Yes. It is exactly the wished behavior

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

Moderators: vistamediajoomlacornerggppdk
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
Save