Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6590d1d
Merge branch '4.2-dev' of https://github.com/joomla/joomla-cms into 4…
Hackwar Aug 8, 2022
4d9f49a
Merge branch '4.3-dev' of https://github.com/joomla/joomla-cms into 4…
Hackwar Aug 30, 2022
f831120
Finder: Add custom fields to search index
Hackwar Aug 31, 2022
dc0d3fb
Codestyle and language string improvement
Hackwar Aug 31, 2022
4b71d98
Merge branch '4.3-dev' of https://github.com/joomla/joomla-cms into 4…
Hackwar Oct 23, 2022
cc17996
Checking if customfields are enabled for this component
Hackwar Oct 23, 2022
d959885
Using constants instead of magic numbers
Hackwar Oct 23, 2022
803ff10
Adding note to update Smart Search index after editing
Hackwar Nov 7, 2022
660ef19
Merge branch '4.3-dev' of https://github.com/joomla/joomla-cms into 4…
Hackwar Nov 7, 2022
92c0ee1
Merge branch '4.3-dev' into 4.2-finder-customfields
Hackwar Nov 9, 2022
a8e5d85
Merge branch '4.3-dev' into 4.2-finder-customfields
Hackwar Nov 11, 2022
725829e
Merge branch '4.3-dev' into 4.2-finder-customfields
Hackwar Nov 16, 2022
e680d65
Merge branch '4.3-dev' into 4.2-finder-customfields
richard67 Jan 6, 2023
6e48091
Merge branch '4.3-dev' into 4.2-finder-customfields
richard67 Jan 22, 2023
58a6893
Merge branch '4.3-dev' into 4.2-finder-customfields
Hackwar Jan 30, 2023
06d7c7f
Merge branch '4.3-dev' of https://github.com/joomla/joomla-cms into 4…
Hackwar Mar 2, 2023
b99ccb9
Codestyle
Hackwar Mar 2, 2023
8e21744
Merge branch '5.0-dev' into 4.2-finder-customfields
Hackwar Mar 28, 2023
bc7999c
Merge branch '5.0-dev' into 4.2-finder-customfields
HLeithner Apr 7, 2023
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 @@ -328,6 +328,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 @@ -80,6 +80,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
35 changes: 35 additions & 0 deletions administrator/components/com_finder/src/Indexer/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,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 @@ -385,6 +386,40 @@ 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
6 changes: 6 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,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="Search Index"
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"
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 @@ -360,6 +360,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 @@ -327,6 +327,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