function renderFields($context, &$row, &$params, $page = 0) { JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'tables'); require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'defineconstants.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.fields.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.helper.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'helpers' . DS . 'permission.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'models' . DS . FLEXI_ITEMVIEW . '.php'; $app = JFactory::getApplication(); $user = JFactory::getUser(); $aid = JAccess::getAuthorisedViewLevels($user->id); $itemmodel = new FlexicontentModelItem(); $item = $itemmodel->getItem($row->id, $check_view_access = false); $view = 'com_content.article' ? FLEXI_ITEMVIEW : 'category'; $items = FlexicontentFields::getFields($item, $view, $_item_params = null, $aid = null, $use_tmpl = false); // $_item_params == null means only retrieve fields // Only Render custom fields $displayed_fields = array(); foreach ($item->fields as $field) { if ($field->iscore) { continue; } $displayed_fields[$field->name] = $field; $values = isset($item->fieldvalues[$field->id]) ? $item->fieldvalues[$field->id] : array(); FlexicontentFields::renderField($item, $field, $values, $method = 'display', $view); } if (!count($displayed_fields)) { return null; } // Render the list of groups $field_html = array(); foreach ($displayed_fields as $field_name => $field) { $_values = null; if (!isset($field->display)) { continue; } $field_html[] = ' <div class="fc-field-box"> ' . ($field->parameters->get('display_label') ? ' <span class="flexi label">' . $field->label . '</span>' : '') . ' <div class="flexi value">' . $field->display . '</div> </div> '; } $_display = '<div class="fc-custom-fields-box">' . implode('', $field_html) . '</div>'; return $_display; }
/** * Function to render the item view of a given item id * * @param int $item_id * @return string : the HTML of the item view, also the CSS / JS file would have been loaded * @since 1.5 */ function renderItem($item_id, $view = FLEXI_ITEMVIEW, $ilayout = '') { JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'tables'); require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.fields.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.helper.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'helpers' . DS . 'permission.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'models' . DS . FLEXI_ITEMVIEW . '.php'; $app = JFactory::getApplication(); $user = JFactory::getUser(); $itemmodel = new FlexicontentModelItem(); $item = $itemmodel->getItem($item_id, $check_view_access = false); $aid = JAccess::getAuthorisedViewLevels($user->id); list($item) = FlexicontentFields::getFields($item, $view, $item->parameters, $aid); // Get Item's specific ilayout if ($ilayout == '') { $ilayout = $item->parameters->get('ilayout', ''); } // Get type's ilayout if ($ilayout == '') { $type = JTable::getInstance('flexicontent_types', ''); $type->id = $item->type_id; $type->load(); $type->params = new JRegistry($type->attribs); $ilayout = $type->params->get('ilayout', 'default'); } $this->item =& $item; $this->params_saved = @$this->params; $this->params =& $item->parameters; $this->tmpl = '.item.' . $ilayout; $this->print_link = JRoute::_('index.php?view=' . FLEXI_ITEMVIEW . '&id=' . $item->slug . '&pop=1&tmpl=component'); $this->pageclass_sfx = ''; if (!isset($this->item->event)) { $this->item->event = new stdClass(); } $this->item->event->beforeDisplayContent = ''; $this->item->event->afterDisplayTitle = ''; $this->item->event->afterDisplayContent = ''; $this->fields =& $this->item->fields; // start capturing output into a buffer ob_start(); // Include the requested template filename in the local scope (this will execute the view logic). if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . $ilayout)) { include JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . $ilayout . DS . 'item.php'; } else { if (file_exists(JPATH_COMPONENT . DS . 'templates' . DS . $ilayout)) { include JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'templates' . DS . $ilayout . DS . 'item.php'; } else { include JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'templates' . DS . 'default' . DS . 'item.php'; } } // done with the requested template; get the buffer and clear it. $item_html = ob_get_contents(); ob_end_clean(); $this->params = $this->params_saved; return $item_html; }