[SOLVED] update item with custom field

More
7 years 4 months ago #65075 by fopo-web
Do you have new informations?

I hope you can help me.

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

More
7 years 4 months ago #65076 by ggppdk
aahh, i forgot / missed looking into this

and do want to update FAQ for existing items
will check this tomorrow, don't hesitate to post reminder on Synday if you get no response


-- 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
7 years 3 months ago #65083 by fopo-web
A Reminder! ;)

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

More
7 years 3 months ago - 7 years 3 months ago #65086 by ggppdk
Hello

I have added a new method (for v3.1.2) and update the FAQ article too
How to create a new FLEXIcontent item or edit an existing item by calling the FLEXIcontent item model in custom code


You can use:
Code:
$items_custom_values = FlexicontentFields::getCustomFieldValues(array($item), 'item'); $data['custom'] = reset($items_custom_values); // Get data of first item
If your site is not live yet, then visit this URL: github.com/FLEXIcontent/flexicontent-cck/tree/3.1.x-stable

Click "Clone or Download" / "Download ZIP"

Then upgrade your existing FLEXIcontent installation,
by uploading the file via Joomla extension installer


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

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

More
7 years 3 months ago - 7 years 3 months ago #65087 by ggppdk
If you do not want to upgrade then copy the new method into your code (use the following):
Code:
function getCustomFieldValues(&$items, $view = 'item') { $custom = FlexicontentFields::_getCustomValues($items, $view); $db = JFactory::getDBO(); $query = 'SELECT *' .' FROM #__flexicontent_fields'; $db->setQuery($query); $fields = $db->loadObjectList('id'); $data = array(); foreach($custom as $item_id => $fdata) { foreach($fdata as $fid => $fvalues) { if ( !isset($fields[$fid]) ) continue; // Make sure field values is an array if ( !is_array($fvalues) ) { $fvalues = strlen($fvalues) ? array($fvalues) : array(); } // Unserialize values already serialized values foreach ($fvalues as $i => $val) { if ( @unserialize($val)!== false || $val === 'b:0;' ) { $fvalues[$i] = unserialize($val); } } $data[$item_id][$fields[$fid]->name] = $fvalues; } } return $data; }



and then use:
Code:
$items_custom_values = getCustomFieldValues(array($item), 'item'); $data['custom'] = reset($items_custom_values); // Get data of first item


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

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

More
7 years 3 months ago #65114 by fopo-web
Thanks for your help. This is the solution. :)

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

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