Getting error on creating item by calling FLEXIcontent item model in custom code

More
6 years 1 month ago #72493 by ggppdk
Hello

i retested with the exact code that the FAQ article has
and it is working with v3.2.1.12

are you running it from an external script (that loads Joomla framework manually)
or from inside a Joomla extension ?


-- 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.

More
6 years 1 month ago - 6 years 1 month ago #72494 by Ali_wdm
Editor removes some code. So I am attaching file. Please go through function onAjaxCreateSubItems()

File Attachment:

File Name: subitem_20...3-24.txt
File Size:34 KB
Attachments:
Last edit: 6 years 1 month ago by Ali_wdm.

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

More
6 years 1 month ago #72495 by Ali_wdm
This code is not working in ajax call using com_ajax.
I have written this code in separate file and make ajax call, everything is working fine. What is problem in ajax call using com_ajax...??

How to get newly created item id...???
How to delete item by custom code...??

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

More
6 years 1 month ago - 6 years 1 month ago #72496 by ggppdk
Hello

about the specific error that you are getting

replace:
Code:
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');

with:
Code:
JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_flexicontent'.DS.'tables');

and it will work

About getting the ID of the new item
Code:
if ( !$item_model->store($data) ) { $msg = 'Failed to store item: '. $item_model->getError(); JLog::add($msg); echo $msg."<br/>"; }

you can use:
Code:
echo $item_model->get('id');


-- 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...
Last edit: 6 years 1 month ago by ggppdk.

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

More
6 years 1 month ago #72497 by Ali_wdm
Thanks a lot.
How to delete item by ajax call....?

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

More
6 years 1 month ago #72500 by ggppdk
Hello

security concerns about creating and deleteing via custom code

Please note that the DB model only does what the controllers tell it
- so when you are using the the DB item model directly via custom code

then you realize that you also need to check ACL ?
someone can access these URLs and do thing in you website

also an alternative to using the DB item model directly

would be you instatiate a FLEXIcontent controller instance
and call its tasks, that would also include ACL checks

$controller = new ...controller class name ...

// then set data into $POST

// Then call

$controller->save();
$controller->delete();

just the above will do filtering and ACL checks for current user

so it depends who has access to run your custom scripts


-- 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.320 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