No intro or full text in selcted favorites

2 months 3 weeks ago #7 by Henri
Hello Christopher,

I read this topic with interest, and tried to display a specific field from flexicontent.
The name of this field is 'activite' and its id = 30

I used your request,
$db = JFactory::getDBO();
$db->setQuery('SELECT `activite` FROM `#__content` WHERE `id` = "'.$item->object->id.'"');
$texts = $db->loadObject();

but I still get the same answer: Unknown column 'activite' in 'field list'

I'm not very pro with php, and I was wondering if you had an idea to display the contents of this field?
Tanks a lot

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

1 month 3 weeks ago #8 by Christopher Mavros
Hello Henri and thank you for posting.
I'm very sorry for the quite late reaction.

The field you are trying to load is not located in the `#__content` table of the database. Judging from the fact that you are using FlexiContent, the field you are looking for, should be in the table `#__flexicontent_fields_item_relations` where the `field_id` is found from the table `#__flexicontent_fields` (the "activitite" is in the name column) and the `item_id` should be the ID you already had.

So it might end up to something like this (simplified):
$db = JFactory::getDBO();
$db->setQuery('SELECT `field_id` FROM `#__flexicontent_fields` WHERE `name` = "activite"');
$field_id = $db->loadResult();
$db->setQuery('SELECT `value` FROM `#__flexicontent_fields_item_relations` WHERE `field_id` = "'.$field_id.'" AND `item_id` = "'.$item->object->id.'"');
$value = $db->loadResult();

Christopher Mavros
mavrosxristoforos@gmail.com
Serving the Joomla! community with extensions since 2008.

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

Moderators: Christopher Mavros