diff --git a/plugins/system/fields/fields.php b/plugins/system/fields/fields.php index 5d68764ffed7a..297baa493d8cf 100644 --- a/plugins/system/fields/fields.php +++ b/plugins/system/fields/fields.php @@ -320,6 +320,15 @@ private function display($context, $item, $params, $displayType) $context = $parts[0] . '.' . $parts[1]; + // Convert tags + if ($context == 'com_tags.tag' && !empty($item->type_alias)) + { + // Set the context + $context = $item->type_alias; + + $item = $this->prepareTagItem($item); + } + if (is_string($params) || !$params) { $params = new Registry($params); @@ -397,7 +406,18 @@ public function onContentPrepare($context, $item) return; } - $fields = FieldsHelper::getFields($parts[0] . '.' . $parts[1], $item, true); + $context = $parts[0] . '.' . $parts[1]; + + // Convert tags + if ($context == 'com_tags.tag' && !empty($item->type_alias)) + { + // Set the context + $context = $item->type_alias; + + $item = $this->prepareTagItem($item); + } + + $fields = FieldsHelper::getFields($context, $item, true); // Adding the fields to the object $item->jcfields = array(); @@ -468,4 +488,28 @@ public function onPrepareFinderContent($item) return true; } + + /** + * Prepares a tag item to be ready for com_fields. + * + * @param stdClass $item The item + * + * @return object + * + * @since __DEPLOY_VERSION__ + */ + private function prepareTagItem($item) + { + // Map core fields + $item->id = $item->content_item_id; + $item->language = $item->core_language; + + // Also handle the catid + if (!empty($item->core_catid)) + { + $item->catid = $item->core_catid; + } + + return $item; + } }