[SOLVED] update item with custom field

More
9 years 5 months ago - 9 years 5 months ago #64806 by ggppdk
Hello

aaah yes,
FlexicontentModelItem
inherits the method:

getItem() and not the load()

so you need to use getItem()

e.g.
Code:
$item_ID = 444; $itemmodel->getItem($item_ID, $check_view_access=false, $no_cache=true, $force_version=0);

The parent class and the method are these:
github.com/FLEXIcontent/flexicontent-cck...ntclassitem.php#L298


- i ll make tests and update the FAQ artilce tomorrow late evening (UTC+2),


-- 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!
Last edit: 9 years 5 months ago by ggppdk.

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

More
9 years 5 months ago #64807 by fopo-web
Sorry, it does not work: :(

My code:
Code:
$itemmodel = new FlexicontentModelItem(); $item = $itemmodel->getItem(368);

I get the error like in my first post:
Code:
<br /> <b>Fatal error</b>: Call to undefined method FlexicontentModelItem::_loadItemParams() in <b>/usr/www/users/fopozw/snowfun/snowfun/administrator/components/com_flexicontent/models/parentclassitem.php</b> on line <b>322</b> <br />

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

More
9 years 5 months ago #64808 by ggppdk
Hello

The parent class of the ITEM model,
- thinks that you are in Joomla frontend

so it tries to use:
_loadItemParams()

- which only exist in FlexicontentModelItem of frontend ,

Solution:

instead of:
require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_flexicontent'.DS.'models'.DS.'item.php');

do
require_once(JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'models'.DS.'item.php');


thus you will load the frontend model


-- 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
9 years 5 months ago #64809 by fopo-web
:(

The load of the item now works, but I can not save.
Code:
require_once(JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'models'.DS.'item.php'); $itemmodel = new FlexicontentModelItem(); $item = $itemmodel->getItem($area->id); $itemmodel->store($item);

Error:
Code:
<br /> <b>Fatal error</b>: Cannot use object of type stdClass as array in <b>/usr/www/users/fopozw/snowfun/snowfun/administrator/components/com_flexicontent/models/parentclassitem.php</b> on line <b>1688</b> <br />

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

More
9 years 5 months ago #64810 by ggppdk
Hello


you need to set:
new data to
$data ARRAY (see the FAQ article)

any data you do not set will maintain their existing value
only use $item to get an existing value

Code:
$item = $itemmodel->getItem($area->id); $data[...] = ...; // see FAQ article $itemmodel->store($data)


-- 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
9 years 5 months ago #64868 by fopo-web
Hi,

Now it works. Thanks for your help.


Regards,

Frank

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

More
9 years 4 months ago #64954 by fopo-web
Hi, I thing I have found a bug in the flexicontent api.

I set some custom values like this and save the item.

$item = $value;

After saving, my other custom fields (which I have not modified) will be cleared. It will not be maintain with the exisiting value.

What can I do?

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

More
9 years 4 months ago #64957 by ggppdk
Hello

yes, we need to update the FAQ article about how to load the existing values into the data array,
before calling the save operation on DB model

i ll update it today or tommorow


-- 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
9 years 4 months ago #64969 by fopo-web
Hi, do you have updated the FAQ?


regards,

Frank

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

More
9 years 4 months ago #64972 by ggppdk
Hello

try this it should work:
1. call
Code:
$data['custom'] = FlexicontentFields::_getCustomValues(array($item), 'item');

2. then change the values of $data

and post back here


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

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