display good currency in template

This commit is contained in:
Manuel Raynaud
2013-09-09 21:17:01 +02:00
parent bf46a937c0
commit 1bf2d02477
2 changed files with 23 additions and 3 deletions

View File

@@ -31,6 +31,7 @@ use Thelia\Core\Template\ParserContext;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Model\CategoryQuery;
use Thelia\Model\ContentQuery;
use Thelia\Model\CurrencyQuery;
use Thelia\Model\FolderQuery;
use Thelia\Model\Product;
use Thelia\Model\ProductQuery;
@@ -132,6 +133,24 @@ class DataAccessFunctions extends AbstractSmartyPlugin
}
}
/**
* currency global data
*
* @param $params
* @param $smarty
*/
public function currencyDataAccess($params, $smarty)
{
$currency = $this->request->getSession()->getCurrency();
if ($currency) {
$currencyQuery = CurrencyQuery::create()
->filterById($currency->getId());
return $this->dataAccessWithI18n("Currency", $params, $currencyQuery, array("NAME"));
}
}
/**
* @param $objectLabel
* @param $params
@@ -231,6 +250,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
new SmartyPluginDescriptor('function', 'category', $this, 'categoryDataAccess'),
new SmartyPluginDescriptor('function', 'content', $this, 'contentDataAccess'),
new SmartyPluginDescriptor('function', 'folder', $this, 'folderDataAccess'),
new SmartyPluginDescriptor('function', 'currency', $this, 'currencyDataAccess'),
);
}
}

View File

@@ -130,10 +130,10 @@ URL: http://www.thelia.net
<div class="currency-switch" aria-labelledby="currency-label">
<span id="currency-label" class="dropdown-label">{intl l="Currency"}:</span>
<a class="current dropdown-toggle" data-toggle="dropdown" href="currency.html">USD</a>
<a class="current dropdown-toggle" data-toggle="dropdown" href="currency.html">{currency attr="code"}</a>
<ul class="select dropdown-menu">
{loop type="currency" name="currency_available" }
<li><a href="?cur=euro">{#SYMBOL} - {#NAME}</a></li>
{loop type="currency" name="currency_available" exclude="{currency attr="id"}" }
<li><a href="?currency={#ISOCODE}">{#SYMBOL} - {#NAME}</a></li>
{/loop}
</ul>
</div>