add post and edito to search + tpl edito
This commit is contained in:
parent
0113e5109a
commit
ba5812bb12
@ -1,2 +1,2 @@
|
||||
<?xml version="1.0"?>
|
||||
<modules_list><modules type="untrusted"><module name="bankwire"/><module name="blockadshooks"/><module name="blockadvertising"/><module name="blockbanner"/><module name="blockbestsellers"/><module name="blockcart"/><module name="blockcategories"/><module name="blockcms"/><module name="blockcmsinfo"/><module name="blockcontact"/><module name="blockcontactinfos"/><module name="blockcurrencies"/><module name="blockcustomerprivacy"/><module name="blocklanguages"/><module name="blocklayered"/><module name="blocklink"/><module name="blockmanufacturer"/><module name="blockmyaccount"/><module name="blockmyaccountfooter"/><module name="blocknewproducts"/><module name="blocknewsletter"/><module name="blockpaymentlogo"/><module name="blockpermanentlinks"/><module name="blockreinsurance"/><module name="blockrss"/><module name="blocksearch"/><module name="blocksharefb"/><module name="blocksocial"/><module name="blockspecials"/><module name="blockstore"/><module name="blocksupplier"/><module name="blocktags"/><module name="blocktopmenu"/><module name="blockuserinfo"/><module name="blockviewed"/><module name="blockwishlist"/><module name="categorieshome"/><module name="cheque"/><module name="cms_comments"/><module name="cms_extrafields"/><module name="cms_menu"/><module name="cms_pack"/><module name="cmsps"/><module name="cronjobs"/><module name="crossselling"/><module name="dashactivity"/><module name="dashgoals"/><module name="dashproducts"/><module name="dashtrends"/><module name="gamification"/><module name="graphnvd3"/><module name="gridhtml"/><module name="homefeatured"/><module name="homeslider"/><module name="pagesnotfound"/><module name="productcomments"/><module name="productpaymentlogos"/><module name="productscategory"/><module name="producttooltip"/><module name="referralprogram"/><module name="sekeywords"/><module name="sendtoafriend"/><module name="seourl"/><module name="socialsharing"/><module name="statsbestcategories"/><module name="statsbestcustomers"/><module name="statsbestmanufacturers"/><module name="statsbestproducts"/><module name="statsbestsuppliers"/><module name="statsbestvouchers"/><module name="statscarrier"/><module name="statscatalog"/><module name="statscheckup"/><module name="statsdata"/><module name="statsequipment"/><module name="statsforecast"/><module name="statslive"/><module name="statsnewsletter"/><module name="statsorigin"/><module name="statspersonalinfos"/><module name="statsproduct"/><module name="statsregistrations"/><module name="statssales"/><module name="statssearch"/><module name="statsstock"/><module name="statsvisits"/><module name="trackingfront"/><module name="vatnumber"/></modules></modules_list>
|
||||
<modules_list><modules type="untrusted"><module name="bankwire"/><module name="blockadshooks"/><module name="blockadvertising"/><module name="blockbanner"/><module name="blockbestsellers"/><module name="blockcart"/><module name="blockcategories"/><module name="blockcms"/><module name="blockcmsinfo"/><module name="blockcontact"/><module name="blockcontactinfos"/><module name="blockcurrencies"/><module name="blockcustomerprivacy"/><module name="blocklanguages"/><module name="blocklink"/><module name="blockmanufacturer"/><module name="blockmyaccount"/><module name="blockmyaccountfooter"/><module name="blocknewproducts"/><module name="blocknewsletter"/><module name="blockpaymentlogo"/><module name="blockpermanentlinks"/><module name="blockreinsurance"/><module name="blockrss"/><module name="blocksearch"/><module name="blocksharefb"/><module name="blocksocial"/><module name="blockspecials"/><module name="blockstore"/><module name="blocksupplier"/><module name="blocktags"/><module name="blocktopmenu"/><module name="blockuserinfo"/><module name="blockviewed"/><module name="blockwishlist"/><module name="categorieshome"/><module name="cheque"/><module name="cms_comments"/><module name="cms_extrafields"/><module name="cms_menu"/><module name="cms_pack"/><module name="cmsps"/><module name="cronjobs"/><module name="crossselling"/><module name="dashactivity"/><module name="dashgoals"/><module name="dashproducts"/><module name="dashtrends"/><module name="graphnvd3"/><module name="gridhtml"/><module name="homefeatured"/><module name="homeslider"/><module name="pagesnotfound"/><module name="productcomments"/><module name="productpaymentlogos"/><module name="productscategory"/><module name="producttooltip"/><module name="referralprogram"/><module name="sekeywords"/><module name="sendtoafriend"/><module name="seourl"/><module name="socialsharing"/><module name="vatnumber"/></modules></modules_list>
|
||||
|
@ -85,7 +85,7 @@
|
||||
if(action == 'up') {
|
||||
var new_value = actual + parseInt(1);
|
||||
} else if(action == 'down') {
|
||||
if(actual == 0) {
|
||||
if(actual == 0) {
|
||||
var new_value = actual;
|
||||
} else {
|
||||
var new_value = actual - parseInt(1);
|
||||
|
@ -65,5 +65,33 @@ class CmsPsEdito extends ObjectModel {
|
||||
|
||||
return $articles = $collection_post->getResults();
|
||||
}
|
||||
|
||||
|
||||
public static function search($query, $limit, $id_lang)
|
||||
{
|
||||
$result = array();
|
||||
$query_posts = '
|
||||
SELECT p.`id_edito`
|
||||
FROM `'._DB_PREFIX_.'cmsps_editos` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'cmsps_editos_lang` pl ON(p.`id_edito` = pl.`id_edito`)
|
||||
WHERE p.`active` = 1
|
||||
AND (
|
||||
pl.`title` LIKE "%'.pSql($query).'%"
|
||||
OR pl.`content` LIKE "%'.pSql($query).'%"
|
||||
)
|
||||
ORDER BY p.`date_add` DESC
|
||||
LIMIT '.(int)$limit
|
||||
;
|
||||
$ids = Db::getInstance()->executeS($query_posts);
|
||||
|
||||
if ($ids) {
|
||||
foreach ($ids as $key => $id) {
|
||||
$result[] = new CmsPsEdito($id['id_edito'], $id_lang);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -330,6 +330,33 @@ class CmsPsPost extends ObjectModel {
|
||||
}
|
||||
}
|
||||
|
||||
public static function search($query, $limit, $id_lang)
|
||||
{
|
||||
$result = array();
|
||||
$query_posts = '
|
||||
SELECT p.`id_post`
|
||||
FROM `'._DB_PREFIX_.'cmsps_posts` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'cmsps_posts_lang` pl ON(p.`id_post` = pl.`id_post`)
|
||||
WHERE p.`active` = 1
|
||||
AND (
|
||||
pl.`title` LIKE "%'.pSql($query).'%"
|
||||
OR pl.`content` LIKE "%'.pSql($query).'%"
|
||||
)
|
||||
ORDER BY p.`note` DESC
|
||||
LIMIT '.(int)$limit
|
||||
;
|
||||
$ids = Db::getInstance()->executeS($query_posts);
|
||||
|
||||
if ($ids) {
|
||||
foreach ($ids as $key => $id) {
|
||||
$result[] = new CmsPsPost($id['id_post'], $id_lang);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result)
|
||||
return self::injectsData($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
24
override/controllers/front/SearchController.php
Normal file
24
override/controllers/front/SearchController.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
require _MODULE_DIR_.'/cmsps/cmsps.php';
|
||||
|
||||
class SearchController extends SearchControllerCore
|
||||
{
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
|
||||
if (($query = Tools::getValue('search_query', Tools::getValue('ref'))) && !is_array($query)) {
|
||||
|
||||
$posts = CmsPsPost::search($query, 15, $this->context->language->id);
|
||||
$editos = CmsPsEdito::search($query, 15, $this->context->language->id);
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'posts' => $posts,
|
||||
'editos' => $editos,
|
||||
'test' => 'test'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
9
themes/toutpratique/edito.tpl
Normal file
9
themes/toutpratique/edito.tpl
Normal file
@ -0,0 +1,9 @@
|
||||
<div class="col-md-{$column} edito">
|
||||
<div class="inner">
|
||||
<h3><a href="{$link->getPostEditoLink($edito->id)}" title="{$edito->title}">{$edito->title}</a></h3>
|
||||
<p>{$edito->intro|substr:0:250}</p>
|
||||
<div class="readmore">
|
||||
<a href="{$link->getPostEditoLink($edito->id)}" title="{$edito->title}">{l s='Lire la suite ...'}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -19,15 +19,7 @@
|
||||
{if $smarty.foreach.edito.index % 2 == 0}
|
||||
<div class="row">
|
||||
{/if}
|
||||
<div class="col-md-6 edito">
|
||||
<div class="inner">
|
||||
<h3><a href="{$link->getPostEditoLink($edito->id)}" title="{$edito->title}">{$edito->title}</a></h3>
|
||||
<p>{$edito->intro|substr:0:250}</p>
|
||||
<div class="readmore">
|
||||
<a href="{$link->getPostEditoLink($edito->id)}" title="{$edito->title}">{l s='Lire la suite ...'}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{include file="./edito.tpl" post=$edito column=6}
|
||||
{if $smarty.foreach.edito.index % 2 == 1}
|
||||
</div>
|
||||
{/if}
|
||||
|
@ -11,21 +11,7 @@
|
||||
{/if}
|
||||
<div class="container">
|
||||
<h1>
|
||||
{l s='Search'}
|
||||
{if $nbProducts > 0}
|
||||
<span class="lighter">
|
||||
"{if isset($search_query) && $search_query}{$search_query|escape:'html':'UTF-8'}{elseif $search_tag}{$search_tag|escape:'html':'UTF-8'}{elseif $ref}{$ref|escape:'html':'UTF-8'}{/if}"
|
||||
</span>
|
||||
{/if}
|
||||
{if isset($instant_search) && $instant_search}
|
||||
<a href="#" class="close">
|
||||
{l s='Return to the previous page'}
|
||||
</a>
|
||||
{else}
|
||||
<span class="heading-counter">
|
||||
{if $nbProducts == 1}{l s='%d result has been found.' sprintf=$nbProducts|intval}{else}{l s='%d results have been found.' sprintf=$nbProducts|intval}{/if}
|
||||
</span>
|
||||
{/if}
|
||||
{l s='Search'}
|
||||
</h1>
|
||||
</div>
|
||||
</header>
|
||||
@ -33,16 +19,36 @@
|
||||
{include file="$tpl_dir./errors.tpl"}
|
||||
|
||||
<div class="container account">
|
||||
{if !$nbProducts}
|
||||
<p class="alert alert-warning">
|
||||
{if isset($search_query) && $search_query}
|
||||
{l s='No results were found for your search'} "{if isset($search_query)}{$search_query|escape:'html':'UTF-8'}{/if}"
|
||||
{elseif isset($search_tag) && $search_tag}
|
||||
{l s='No results were found for your search'} "{$search_tag|escape:'html':'UTF-8'}"
|
||||
{else}
|
||||
{l s='Please enter a search keyword'}
|
||||
{/if}
|
||||
</p>
|
||||
|
||||
{if $posts}
|
||||
<h3 class="subtitle">{l s='Articles'}</h3>
|
||||
<div class="row">
|
||||
{foreach from=$posts item=post key=key}
|
||||
<div class="col-md-4 col-sm-4">
|
||||
{include file="./post_img.tpl" post=$post}
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
<div class="separator"></div>
|
||||
{/if}
|
||||
|
||||
{if $editos}
|
||||
<h3 class="subtitle">{l s='Editos'}</h3>
|
||||
<div class="row">
|
||||
{foreach from=$editos item=edito name=edito}
|
||||
{if $smarty.foreach.edito.index % 4 == 0}
|
||||
<div class="row">
|
||||
{/if}
|
||||
{include file="./edito.tpl" post=$edito column=3}
|
||||
{if $smarty.foreach.edito.index % 4 == 3}
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</div>
|
||||
<div class="separator"></div>
|
||||
{/if}
|
||||
|
||||
{if !$nbProducts}
|
||||
{else}
|
||||
{if isset($instant_search) && $instant_search}
|
||||
<p class="alert alert-info">
|
||||
@ -51,9 +57,9 @@
|
||||
{/if}
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-sm-6 col-xs-6 col-xxs-12 pull-right">
|
||||
<div class="form-group">
|
||||
<!-- <div class="form-group">
|
||||
{include file="$tpl_dir./product-sort.tpl"}
|
||||
</div>
|
||||
</div> -->
|
||||
{if !isset($instant_search) || (isset($instant_search) && !$instant_search)}
|
||||
{include file="./nbr-product-page.tpl"}
|
||||
{/if}
|
||||
|
Loading…
Reference in New Issue
Block a user