JLoader::register('DPFieldsHelper', JPATH_ADMINISTRATOR . '/components/com_dpfields/helpers/dpfields.php'); $parts = explode('.', $context); $component = $parts[0]; // Load some output definitions $container = 'dl'; if (key_exists('container', $displayData) && $displayData['container']) { $container = $displayData['container']; } $class = 'article-info muted'; if (key_exists('container-class', $displayData) && $displayData['container-class']) { $class = $displayData['container-class']; } // Print the container tag echo '<' . $container . ' class="' . $class . '">'; // Loop trough the fields and print them foreach (DPFieldsHelper::getFields($context, $item, true) as $field) { // If the value is empty dp nothing if (!isset($field->value) || !$field->value) { continue; } $output = JLayoutHelper::render('field.render', array('label' => $field->label, 'value' => $field->value), null, array('component' => $component, 'client' => 0)); /* * Because the layout refreshes the paths before the render function is * called, so there is no way to load the layout overrides in the order * template -> context -> dpfields. * If there is no override in the context then we need to call the layout * from DPField. */ if (!$output) { $output = JLayoutHelper::render('field.render', array('label' => $field->label, 'value' => $field->value), null, array('component' => 'com_dpfields', 'client' => 0)); }
public function onPrepareFinderContent($item) { $section = strtolower($item->layout); $tax = $item->getTaxonomy('Type'); if ($tax) { foreach ($tax as $context => $value) { // This is only a guess, needs to be improved $component = strtolower($context); if (strpos($context, 'com_') !== 0) { $component = 'com_' . $component; } // Transofrm com_article to com_content if ($component == 'com_article') { $component = 'com_content'; } // Create a dummy object with the required fields $tmp = new stdClass(); $tmp->id = $item->__get('id'); if ($item->__get('catid')) { $tmp->catid = $item->__get('catid'); } // Getting the fields for the constructed context $fields = DPFieldsHelper::getFields($component . '.' . $section, $tmp, true); if (is_array($fields)) { foreach ($fields as $field) { // Adding the instructions how to handle the text $item->addInstruction(FinderIndexer::TEXT_CONTEXT, $field->alias); // Adding the field value as a field $item->{$field->alias} = $field->value; } } } } return true; }
if (!key_exists('item', $displayData) || !key_exists('context', $displayData)) { return; } // Setting up for display $item = $displayData['item']; if (!$item) { return; } $context = $displayData['context']; if (!$context) { return; } JLoader::register('DPFieldsHelper', JPATH_ADMINISTRATOR . '/components/com_dpfields/helpers/dpfields.php'); $parts = explode('.', $context); $component = $parts[0]; $fields = DPFieldsHelper::getFields($context, $item, true); if (!$fields) { return; } // Load some output definitions $container = 'dl'; if (key_exists('container', $displayData) && $displayData['container']) { $container = $displayData['container']; } $class = 'article-info muted'; if (key_exists('container-class', $displayData) && $displayData['container-class']) { $class = $displayData['container-class']; } // Print the container tag echo '<' . $container . ' class="' . $class . '">'; // Loop trough the fields and print them