diff --git a/administrator/components/com_fields/forms/field.xml b/administrator/components/com_fields/forms/field.xml index 68becf1523927..19fb8a53dae38 100644 --- a/administrator/components/com_fields/forms/field.xml +++ b/administrator/components/com_fields/forms/field.xml @@ -328,6 +328,20 @@ +
+ + + + + + +
diff --git a/administrator/components/com_fields/tmpl/field/edit.php b/administrator/components/com_fields/tmpl/field/edit.php index a357d89c7928b..1a6f95a144c16 100644 --- a/administrator/components/com_fields/tmpl/field/edit.php +++ b/administrator/components/com_fields/tmpl/field/edit.php @@ -77,6 +77,7 @@
+ form->renderField('searchindexing'); ?>
diff --git a/administrator/components/com_finder/src/Indexer/Helper.php b/administrator/components/com_finder/src/Indexer/Helper.php index fc3f13ab97794..8539c76707ce7 100644 --- a/administrator/components/com_finder/src/Indexer/Helper.php +++ b/administrator/components/com_finder/src/Indexer/Helper.php @@ -17,6 +17,7 @@ use Joomla\CMS\Language\Multilanguage; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Table\Table; +use Joomla\Component\Fields\Administrator\Helper\FieldsHelper; use Joomla\Registry\Registry; use Joomla\String\StringHelper; @@ -432,6 +433,43 @@ public static function getContentExtras(Result $item) return true; } + /** + * Add custom fields for the item to the Result object + * + * @param Result $item Result object to add the custom fields to + * @param string $context Context of the item in the custom fields + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public static function addCustomFields(Result $item, $context) + { + $obj = new \stdClass; + $obj->id = $item->id; + + $fields = FieldsHelper::getFields($context, $obj, true); + + foreach ($fields as $field) + { + $searchindex = $field->params->get('searchindex', 0); + + // We want to add this field to the search index + if ($searchindex == 1 || $searchindex == 3) + { + $name = 'jsfield_' . $field->name; + $item->$name = $field->value; + $item->addInstruction(Indexer::META_CONTEXT, $name); + } + + // We want to add this field as a taxonomy + if (($searchindex == 2 || $searchindex == 3) && $field->value) + { + $item->addTaxonomy($field->title, $field->value, $field->state, $field->access, $field->language); + } + } + } + /** * Method to process content text using the onContentPrepare event trigger. * diff --git a/administrator/language/en-GB/com_fields.ini b/administrator/language/en-GB/com_fields.ini index 138475daa335c..c8573bf25d9ad 100644 --- a/administrator/language/en-GB/com_fields.ini +++ b/administrator/language/en-GB/com_fields.ini @@ -57,8 +57,14 @@ COM_FIELDS_FIELD_RENDER_CLASS_LABEL="Display Class" COM_FIELDS_FIELD_RENDEROPTIONS_HEADING="Display Options" COM_FIELDS_FIELD_REQUIRED_LABEL="Required" COM_FIELDS_FIELD_SAVE_SUCCESS="Field saved" +COM_FIELDS_FIELD_SEARCHINDEX_BOTH="Make searchable and add as taxonomy" +COM_FIELDS_FIELD_SEARCHINDEX_DONT="Don't make searchable" +COM_FIELDS_FIELD_SEARCHINDEX_LABEL="Searchindex" +COM_FIELDS_FIELD_SEARCHINDEX_SEARCHABLE="Make searchable" +COM_FIELDS_FIELD_SEARCHINDEX_TAXONOMY="Add as taxonomy" COM_FIELDS_FIELD_SHOWLABEL_DESC="Show or Hide the label when the field displays." COM_FIELDS_FIELD_SHOWLABEL_LABEL="Label" +COM_FIELDS_FIELD_SMARTSEARCHOPTIONS_HEADING="Smart Search" COM_FIELDS_FIELD_SUFFIX_LABEL="Suffix" COM_FIELDS_FIELD_TYPE_LABEL="Type" COM_FIELDS_FIELD_USE_GLOBAL="Use settings from Plugin" diff --git a/plugins/finder/contacts/contacts.php b/plugins/finder/contacts/contacts.php index 45b587ccdbe1f..b916ebc134584 100644 --- a/plugins/finder/contacts/contacts.php +++ b/plugins/finder/contacts/contacts.php @@ -387,6 +387,7 @@ protected function index(Result $item) // Get content extras. Helper::getContentExtras($item); + Helper::addCustomFields($item, 'com_contact.contact'); // Index the item. $this->indexer->index($item); diff --git a/plugins/finder/content/content.php b/plugins/finder/content/content.php index dd18a3b4818ba..a3d1f707b2a22 100644 --- a/plugins/finder/content/content.php +++ b/plugins/finder/content/content.php @@ -343,6 +343,7 @@ protected function index(Result $item) // Get content extras. Helper::getContentExtras($item); + Helper::addCustomFields($item, 'com_content.article'); // Index the item. $this->indexer->index($item);