Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions administrator/components/com_fields/forms/field.xml
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,20 @@
<option value="0">JNO</option>
</field>
</fieldset>
<fieldset name="smartsearchoptions" label="COM_FIELDS_FIELD_SMARTSEARCHOPTIONS_HEADING">
<field
name="searchindex"
type="list"
label="COM_FIELDS_FIELD_SEARCHINDEX_LABEL"
default="0"
validate="options"
>
<option value="0">COM_FIELDS_FIELD_SEARCHINDEX_DONT</option>
<option value="1">COM_FIELDS_FIELD_SEARCHINDEX_SEARCHABLE</option>
<option value="2">COM_FIELDS_FIELD_SEARCHINDEX_TAXONOMY</option>
<option value="3">COM_FIELDS_FIELD_SEARCHINDEX_BOTH</option>
</field>
</fieldset>
</fieldset>
</fields>
</form>
1 change: 1 addition & 0 deletions administrator/components/com_fields/tmpl/field/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<legend><?php echo Text::_('JGLOBAL_FIELDSET_PUBLISHING'); ?></legend>
<div>
<?php echo LayoutHelper::render('joomla.edit.publishingdata', $this); ?>
<?php echo $this->form->renderField('searchindexing'); ?>
</div>
</fieldset>
<?php echo HTMLHelper::_('uitab.endTab'); ?>
Expand Down
38 changes: 38 additions & 0 deletions administrator/components/com_finder/src/Indexer/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 == 1 || $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.
*
Expand Down
7 changes: 7 additions & 0 deletions administrator/language/en-GB/com_fields.ini
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,15 @@ COM_FIELDS_FIELD_RENDER_CLASS_LABEL="Render Class"
COM_FIELDS_FIELD_RENDEROPTIONS_HEADING="Render 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 renders."
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"
Expand Down
1 change: 1 addition & 0 deletions plugins/finder/contacts/contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions plugins/finder/content/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down