problem with "How to create a new FLEXIcontent item or update an existing item by calling the FLEXIcontent item model in custom code"

More
6 years 8 months ago #68906 by ggppdk
Hello
Code:
$data['id']
needs also to be set
Code:
$data['id'] = $item_ID;

i will update instructions


-- 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 8 months ago #68907 by ydl
BUT I don't understand ...
the problem was in the call:

$item = $item_model->getItem($item_ID, $check_view_access=false, $no_cache=true, $force_version=0);

so, how to fit what you write in this call

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

More
6 years 8 months ago - 6 years 8 months ago #68908 by ggppdk
Hello

Just set it before calling model 's store()

i have updated the instructions:

www.flexicontent.org/documentation/faq/7...-in-custom-code.html
Code:
// 444 is the id of the item that you want to load, or set it to zero for new item $item_ID = 444; if ($item_ID) { // EITHER Load existing item into the ITEM model $item = $item_model->getItem($item_ID, $check_view_access=false, $no_cache=true, $force_version=0); // You can use $item to get existing values if (!$item) die('item '.$item_ID.' not found'); // IMPORTANT: Get existing field values for the item $items = array($item); $items_custom_values = FlexicontentFields::getCustomFieldValues($items, 'item'); $data['custom'] = reset($items_custom_values); // Get data of first item // Indicate which item to update $data['id'] = $item_ID; } else { // OR indicate a new item will be created $data['id'] = 0; }


-- 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 8 months ago by ggppdk.

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

More
6 years 8 months ago #68916 by ydl
I think I am misunderstood...

The problem is when calling to

$item = $item_model->getItem($schoolId, $check_view_access=false, $no_cache=true, $force_version=0);

and I am getting the error:

Call to a member function load() on boolean...

So, this call is done before getting the 'item'....

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

More
6 years 8 months ago #68917 by ggppdk
Hello

you can put the full code that you are using in a text file
and send it to me with a PM


-- 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 8 months ago #68997 by ydl

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.291 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