fix thelia diese problems
This commit is contained in:
@@ -67,6 +67,10 @@
|
||||
<tag name="thelia.parser.register_plugin"/>
|
||||
</service>
|
||||
|
||||
<service id="smarty.plugin.theliasyntax" class="Thelia\Core\Template\Smarty\Plugins\TheliaSyntax" >
|
||||
<tag name="thelia.parser.register_plugin"/>
|
||||
</service>
|
||||
|
||||
<service id="smarty.plugin.thelialoop" class="Thelia\Core\Template\Smarty\Plugins\TheliaLoop" scope="request">
|
||||
<tag name="thelia.parser.register_plugin"/>
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class LoopResultRow
|
||||
|
||||
public function set($key, $value)
|
||||
{
|
||||
$this->substitution[$key] = $value;
|
||||
$this->substitution[$key] = $value === null ? '' : $value;
|
||||
}
|
||||
|
||||
public function get($key)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Core\Template\Smarty\Plugins;
|
||||
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginInterface;
|
||||
|
||||
/**
|
||||
* Class TheliaSyntax
|
||||
* @package Thelia\Core\Template\Smarty\Plugins
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class TheliaSyntax implements SmartyPluginInterface
|
||||
{
|
||||
public function dieseCancel($value, $diese)
|
||||
{
|
||||
if($value === null) {
|
||||
return $diese;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SmartyPluginDescriptor[]
|
||||
*/
|
||||
public function getPluginDescriptors()
|
||||
{
|
||||
return array(
|
||||
new SmartyPluginDescriptor("modifier", "dieseCanceller", $this, "dieseCancel")
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -29,10 +29,11 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
protected $status = 200;
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
|
||||
* @param bool $template
|
||||
* @param string $env Environment define for the kernel application. Used for the cache directory
|
||||
* @param Request $request
|
||||
* @param EventDispatcherInterface $dispatcher
|
||||
* @param bool $template
|
||||
* @param string $env
|
||||
* @param bool $debug
|
||||
*/
|
||||
public function __construct(Request $request, EventDispatcherInterface $dispatcher, $template = false, $env = "prod", $debug = false)
|
||||
{
|
||||
@@ -78,7 +79,7 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
public function preThelia($tpl_source, \Smarty_Internal_Template $template)
|
||||
{
|
||||
$new_source = preg_replace('`{#([a-zA-Z][a-zA-Z0-9\-_]*)(.*)}`', '{\$$1$2}', $tpl_source);
|
||||
$new_source = preg_replace('`#([a-zA-Z][a-zA-Z0-9\-_]*)`', '{\$$1|default:\'#$1\'}', $new_source);
|
||||
$new_source = preg_replace('`#([a-zA-Z][a-zA-Z0-9\-_]*)`', '{\$$1|dieseCanceller:\'#$1\'}', $new_source);
|
||||
|
||||
return $new_source;
|
||||
}
|
||||
|
||||
@@ -19,10 +19,11 @@
|
||||
<hr />
|
||||
{/loop*}
|
||||
<h2>PRODUCTS</h2>
|
||||
{loop name="product" type="product" min_weight="2.5" max_weight="10"}
|
||||
{loop name="product" type="product"}
|
||||
<h3>PRODUCT : #REF / #TITLE</h3>
|
||||
price : #PRICE €<br />
|
||||
promo price : #PROMO_PRICE €<br />
|
||||
is promo : #PROMO<br />
|
||||
is new : #NEW<br />
|
||||
weight : #WEIGHT<br />
|
||||
{/loop}
|
||||
|
||||
Reference in New Issue
Block a user