fix current url bug + fix empty loop pagination exception

This commit is contained in:
Etienne Roudeix
2013-09-12 17:20:33 +02:00
parent 3f82421879
commit a73c9e1de4
5 changed files with 23 additions and 22 deletions

View File

@@ -67,12 +67,12 @@ class TheliaLoop extends AbstractSmartyPlugin
*
* @return \PropelModelPager
*/
public static function getPagination($loopId)
public static function getPagination($loopName)
{
if (!empty(self::$pagination[$loopId])) {
return self::$pagination[$loopId];
if (array_key_exists($loopName, self::$pagination)) {
return self::$pagination[$loopName];
} else {
return null;
throw new \InvalidArgumentException("Loop $loopName is not defined");
}
}
@@ -242,16 +242,10 @@ class TheliaLoop extends AbstractSmartyPlugin
if (null == $loopName)
throw new \InvalidArgumentException("Missing 'rel' parameter in page loop");
// Find loop results in the current template vars
/* $loopResults = $template->getTemplateVars($loopName);
if (empty($loopResults)) {
throw new \InvalidArgumentException("Loop $loopName is not defined.");
}*/
// Find pagination
$pagination = self::getPagination($loopName);
if ($pagination === null) {
throw new \InvalidArgumentException("Loop $loopName is not defined");
if ($pagination === null) { // loop gas no result
return '';
}
if ($pagination->getNbResults() == 0) {

View File

@@ -56,12 +56,14 @@ class RewritingRetriever
* @param $viewLocale
* @param null $viewId
*/
public function loadViewUrl($view, $viewLocale, $viewId = null)
public function loadViewUrl($view, $viewLocale = null, $viewId = null)
{
$this->search = $this->rewritingUrlQuery->getViewUrlQuery($view, $viewLocale, $viewId);
$allParametersWithoutView = array();
$allParametersWithoutView['locale'] = $viewLocale;
if(null !== $viewId) {
$allParametersWithoutView['locale'] = $viewLocale;
}
if(null !== $viewId) {
$allParametersWithoutView[$view . '_id'] = $viewId;
}

View File

@@ -232,10 +232,10 @@ class URL
$this->retriever->loadSpecificUrl($view, $viewLocale, $viewId, $allOtherParameters);
} else {
$allParametersWithoutView = $viewOtherParameters;
$allParametersWithoutView['locale'] = $viewLocale;
if (null !== $viewId) {
$allParametersWithoutView[$view . '_id'] = $viewId;
$allParametersWithoutView = $request->query->all();
$view = $request->attributes->get('_view');
if(isset($allOtherParameters['view'])) {
unset($allOtherParameters['view']);
}
$this->retriever->rewrittenUrl = null;
$this->retriever->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);

View File

@@ -1,5 +1,8 @@
{*loop type="product" name="fsdq"}
{format_date date=$CREATE_DATE}
{/loop*}
<h1>Category page</h1>
::{product attr="createdAt" output="time" format='i'};;<br />
{loop type="category" name="categoryloop" id="500"}
TOTO
{/loop}
{pageloop rel="categoryloop"}
{/pageloop}

View File

@@ -1,6 +1,8 @@
{include file="includes/header.html"}
<div>
Here you are : {navigate to="current"}
{loop type="auth" name="auth_test" context="front" roles="CUSTOMER"}
<p>Customer is authentified :-)</p>