$db = & JFactory::getDBO(); // Set a different item id if you don't want the current item ... $fcitem_id= JRequest::getInt('id',0); $fccat_id= JRequest::getInt('cid',0); $view= JRequest::getVar('view'); if ($view!='items' && $view!='item' && $view!='article') { return "not in items view"; } // RETRIEVE item data if ($fcitem_id) { $query = 'SELECT c.*' .' FROM '.'#'.'__content AS c ' .' WHERE c.id = ' . $fcitem_id; $db->setQuery($query); $itemdata = $db->loadObject(); $item_title = $itemdata->title; } // NOTE $itemdata now CONTAINS all item's basic fields // (but not values for FLEXIcontent fields) // RETRIEVE item's category data if ($fccat_id) { $query = 'SELECT c.*' .' FROM '.'#'.'__categories AS c' .' WHERE c.id = ' . $fccat_id; $db->setQuery($query); $catdata = $db->loadObject(); $cat_title = $catdata->title; } // NOTE $catdata now CONTAINS all item's category basic fields // FINAL STEP: --IF-- your code is for using in a RSform field // then you need to return it: // so, USE ONE of the following return statements // e.g. return $item_title; //e.g. return $cat_title; // e.g. return $item_title ." - ".$cat_title;
$db = & JFactory::getDBO(); // Set a different item id if you don't want the current item ... $fcitem_id= JRequest::getInt('id',0); $fccat_id= JRequest::getInt('cid',0); $view= JRequest::getVar('view'); if ($view!='items' && $view!='item' && $view!='article') { return "not in items view"; } $field_id=45; // CHANGE THIS TO THE ID OF YOUR FIELD if ($fcitem_id) { $query = 'SELECT c.title, c.alias, f.value' .' FROM '.'#'.'__content AS c ' .' LEFT JOIN '.'#'.'__flexicontent_fields_item_relations AS f' .' ON f.item_id = c.id AND f.field_id='.(int)$field_id .' WHERE c.id = ' . $fcitem_id; $db->setQuery($query); $itemdata = $db->loadObject(); $item_title = $itemdata->title; } return $itemdata->value;
require_once (JPATH_ADMINISTRATOR.DS.'components/com_flexicontent/defineconstants.php'); require_once("components/com_flexicontent/classes/flexicontent.fields.php"); require_once("components/com_flexicontent/classes/flexicontent.helper.php"); $query = 'SELECT * FROM '.'#'.'__flexicontent_fields WHERE id='.(int)$field_id; $db->setQuery($query); $field = $db->loadObject(); $field->parameters = FLEXI_J16GE ? new JRegistry($field->attribs) : new JParameter($field->attribs); $elements = FlexicontentFields::indexedField_getElements( $field, $itemdata ); $label_of_value = $elements[$itemdata->value]->text; return $label_of_value;
NOTE: Click to make this item favourable to be notified of updates
ALSO read this article:
-- Retrieving the HTML DISPLAY of FC fields inside 3rd-party code