implement search on content loop.
This commit is contained in:
@@ -18,6 +18,7 @@ use Thelia\Core\Template\Element\LoopResult;
|
|||||||
use Thelia\Core\Template\Element\LoopResultRow;
|
use Thelia\Core\Template\Element\LoopResultRow;
|
||||||
|
|
||||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||||
|
use Thelia\Core\Template\Element\SearchLoopInterface;
|
||||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ use Thelia\Type\BooleanOrBothType;
|
|||||||
* @package Thelia\Core\Template\Loop
|
* @package Thelia\Core\Template\Loop
|
||||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||||
*/
|
*/
|
||||||
class Content extends BaseI18nLoop implements PropelSearchLoopInterface
|
class Content extends BaseI18nLoop implements PropelSearchLoopInterface, SearchLoopInterface
|
||||||
{
|
{
|
||||||
protected $timestampable = true;
|
protected $timestampable = true;
|
||||||
protected $versionable = true;
|
protected $versionable = true;
|
||||||
@@ -82,6 +83,23 @@ class Content extends BaseI18nLoop implements PropelSearchLoopInterface
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array of available field to search in
|
||||||
|
*/
|
||||||
|
public function getSearchIn()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
"title"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function doSearch(&$search, $searchTerm, $searchIn, $searchCriteria)
|
||||||
|
{
|
||||||
|
$search->_and();
|
||||||
|
|
||||||
|
$search->where("CASE WHEN NOT ISNULL(`requested_locale_i18n`.ID) THEN `requested_locale_i18n`.`TITLE` ELSE `default_locale_i18n`.`TITLE` END ".$searchCriteria." ?", $searchTerm, \PDO::PARAM_STR);
|
||||||
|
}
|
||||||
|
|
||||||
public function buildModelCriteria()
|
public function buildModelCriteria()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -290,7 +290,7 @@
|
|||||||
<td class="actions">
|
<td class="actions">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
{loop type="auth" name="can_change" role="ADMIN" resource="admin.folder" access="UPDATE"}
|
{loop type="auth" name="can_change" role="ADMIN" resource="admin.folder" access="UPDATE"}
|
||||||
<a class="btn btn-default btn-xs" title="{intl l='Edit this product'}" href="{url path='/admin/products/update' product_id=$ID}"><i class="glyphicon glyphicon-edit"></i></a>
|
<a class="btn btn-default btn-xs" title="{intl l='Edit this product'}" href="{url path="/admin/folders/update/{$ID}"}"><i class="glyphicon glyphicon-edit"></i></a>
|
||||||
{/loop}
|
{/loop}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -303,6 +303,49 @@
|
|||||||
</div>
|
</div>
|
||||||
{* end folder search *}
|
{* end folder search *}
|
||||||
|
|
||||||
|
{* content search *}
|
||||||
|
<div class="general-block-decorator">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped table-condensed table-left-aligned">
|
||||||
|
<caption class="clearfix">
|
||||||
|
{intl l='Content'}
|
||||||
|
</caption>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{intl l="ID"}</th>
|
||||||
|
<th></th>
|
||||||
|
<th>{intl l="Content title"}</th>
|
||||||
|
|
||||||
|
<th class="actions">{intl l="Actions"}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
{loop type="content" name="content-search" visible="*" search_mode="sentence" search_term=trim($smarty.get.search_term) search_in="title"}
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>{$ID}</td>
|
||||||
|
<td></td>
|
||||||
|
|
||||||
|
<td class="object-title"><a href="{url path="/admin/content/update/{$ID}"}">{$TITLE}</a></td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="actions">
|
||||||
|
<div class="btn-group">
|
||||||
|
{loop type="auth" name="can_change" role="ADMIN" resource="admin.content" access="UPDATE"}
|
||||||
|
<a class="btn btn-default btn-xs" title="{intl l='Edit this product'}" href="{url path="/admin/content/update/{$ID}"}"><i class="glyphicon glyphicon-edit"></i></a>
|
||||||
|
{/loop}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{/loop}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{* end content search *}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user