Skip to content

Commit

Permalink
added search plugin option to show/hide the list tile in search results
Browse files Browse the repository at this point in the history
  • Loading branch information
pollen8 committed Jan 13, 2014
1 parent 668f89d commit 31a708a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
26 changes: 24 additions & 2 deletions plugins/search/fabrik/fabrik.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,30 @@
<config>
<fields name="params">
<fieldset name="basic">
<field default="50" description="Number of Search items to return" label="Search Limit" name="search_limit" size="5" type="text"/>
<field default="Fabrik/record" description="Appears in search results, under the title." label="Section heading" name="search_section_heading" size="15" type="text"/>

<field name="search_limit"
type="text"
default="50"
description="Number of Search items to return"
label="Search Limit"
size="5" />

<field name="search_section_heading"
default="Fabrik/record"
type="text"
description="Appears in search results, under the title."
label="Section heading"
size="15"/>

<field name="include_list_title"
type="radio"
class="btn-group"
default="1"
label="Include list title in heading">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

</fieldset>
</fields>
</config>
Expand Down
10 changes: 9 additions & 1 deletion plugins/system/fabrik/fabrik.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public function onDoContentSearch($text, $phrase = '', $ordering = '', $areas =
{
return;
}

define('COM_FABRIK_SEARCH_RUN', true);
JModel::addIncludePath(COM_FABRIK_FRONTEND . '/models', 'FabrikFEModel');

Expand All @@ -124,6 +125,7 @@ public function onDoContentSearch($text, $phrase = '', $ordering = '', $areas =
// Load plugin params info
$limit = $this->params->def('search_limit', 50);
$text = trim($text);

if ($text == '')
{
return array();
Expand Down Expand Up @@ -153,6 +155,10 @@ public function onDoContentSearch($text, $phrase = '', $ordering = '', $areas =
$order = 'a.created DESC';
break;
}

// Set heading prefix
$headingPrefix = $params->get('include_list_title', true);

// Get all tables with search on
$query = $db->getQuery(true);
$query->select('id')->from('#__{package}_lists')->where('published = 1');
Expand All @@ -161,10 +167,12 @@ public function onDoContentSearch($text, $phrase = '', $ordering = '', $areas =

$list = array();
$ids = $db->loadColumn();

if ($db->getErrorNum() != 0)
{
jexit('search:' . $db->getErrorMsg());
}

$section = $this->params->get('search_section_heading');
$urls = array();

Expand Down Expand Up @@ -262,7 +270,7 @@ public function onDoContentSearch($text, $phrase = '', $ordering = '', $areas =
$o = new stdClass;
if (isset($oData->$title))
{
$o->title = $table->label . ' : ' . $oData->$title;
$o->title = $headingPrefix ? $table->label . ' : ' . $oData->$title : $oData->$title;
}
else
{
Expand Down

0 comments on commit 31a708a

Please sign in to comment.