[SOLVED] update item with custom field

More
8 years 3 weeks ago - 8 years 3 days ago #64773 by fopo-web
Hi, I read in an own plugin a flexicontent item. f.e.:
Code:
$itemmodel_name = FLEXI_J16GE ? 'FlexicontentModelItem' : 'FlexicontentModelItems'; $itemmodel = new $itemmodel_name(); $item = $itemmodel->getItem($id, $check_view_access=true); $items = array(&$item); FlexicontentFields::getFields($items); FlexicontentFields::getFieldDisplay($item, 'myfield'); $value = $item->fields['myfield']->display;

How can I modify the value of "myfield" and how can I save the item after this?


regards,

Frank
Last edit: 8 years 3 days ago by ggppdk.

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

More
8 years 3 weeks ago - 8 years 3 weeks ago #64774 by ggppdk
Hello

that code you mentioned is for viewing / display item data in item code

Please read this for creating new or changing existing items:
How to create a new FLEXIcontent item or edit an existing item by calling the FLEXIcontent item model in custom code
www.flexicontent.org/documentation/faq/7...-in-custom-code.html


If you have create a new field type then use
onBeforeSaveField() for saving data when saving FLEXIcontent item form:
How to Duplicate a Flexicontent Field to create a new Field Type
www.flexicontent.org/documentation/faq/7...-new-field-type.html


-- 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: 8 years 3 weeks ago by ggppdk.

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

More
8 years 3 weeks ago #64784 by fopo-web
Hi, thanks for your fast answer. I have try it, but I get following error:
Code:
<br /> <b>Fatal error</b>: Call to undefined method FlexicontentModelItem::_loadItemParams() in <b>.../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
8 years 3 weeks ago #64785 by ggppdk
Hello

are you running this from inside Joomla or from custom script ?

are in Joomla Frontend or backend ?

what is the current component of your currently view page (/URL) ?


-- 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
8 years 3 weeks ago #64792 by fopo-web
Hi,

I have written a Joomla Plugin for der Joomla Rest Extension. I want to show and modify items in a android app. The reading of my items works (GET), but If I want modify an item I will get the error above.

My code:
Code:
<?php // No direct access. defined('_JEXEC') or die; jimport('joomla.application.component.model'); require_once (JPATH_ADMINISTRATOR.DS.'components/com_flexicontent/defineconstants.php'); require_once(JPATH_SITE.DS."components/com_flexicontent/classes/flexicontent.helper.php"); require_once(JPATH_SITE.DS."components/com_flexicontent/classes/flexicontent.categories.php"); require_once(JPATH_SITE.DS."components/com_flexicontent/classes/flexicontent.fields.php"); require_once(JPATH_SITE.DS."components/com_flexicontent/classes/flexicontent.acl.php"); require_once(JPATH_SITE.DS."components/com_flexicontent/helpers/permission.php"); require_once(JPATH_SITE.DS."components/com_flexicontent/helpers/route.php"); require_once(JPATH_SITE.DS."components/com_content/helpers/route.php"); JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_flexicontent'.DS.'tables'); class SnowfunApiResourceTest extends ApiResource { public function get() { ... } public function post() { $app = JFactory::getApplication(); $tmp = $app->input->get('param', '', 'STRING'); $area = json_decode($tmp); require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_flexicontent'.DS.'models'.DS.'item.php'); $itemmodel = new FlexicontentModelItem(); $item = $itemmodel->getItem($area->id); $item['custom']['myfield'] = $area->fieldValue; $itemmodel->store($item); $this->plugin->setResponse( $item ); } }

I have no idea.

regards,

Frank

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

More
8 years 3 weeks ago #64805 by fopo-web

ggppdk wrote: Please read this for creating new or changing existing items:
How to create a new FLEXIcontent item or edit an existing item by calling the FLEXIcontent item model in custom code
www.flexicontent.org/documentation/faq/7...-in-custom-code.html


Is it possible that this documention not work for existing items? There is no method "load" in FlexicontentModelItem. I can use getItem, but I get an error on store the item, because the item is an object and not an array.

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

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