From 4bd971e625e50a2a63afed48641e5e7174e57f4e Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Mon, 8 Jul 2013 11:52:10 +0200 Subject: [PATCH] pagination sample --- .../Template/Smarty/Plugins/TheliaLoop.php | 6 +- templates/smarty-sample/pagination.html | 55 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100755 templates/smarty-sample/pagination.html diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php index 86a29da6d..0e02ec5e9 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php @@ -220,7 +220,11 @@ class TheliaLoop implements SmartyPluginInterface // Find pagination $pagination = self::getPagination($loopName); if ($pagination === null) { - throw new \InvalidArgumentException("Loop $loopName : no pagination found."); + throw new \InvalidArgumentException("Loop $loopName is not defined"); + } + + if($pagination->getNbResults() == 0) { + return ''; } if ($content === null) { diff --git a/templates/smarty-sample/pagination.html b/templates/smarty-sample/pagination.html new file mode 100755 index 000000000..5a5182177 --- /dev/null +++ b/templates/smarty-sample/pagination.html @@ -0,0 +1,55 @@ +{assign var=category_current_page value={$smarty.get.category_page|default:1}} + +

Pagination

+ +

Categories

+ +
+ +{loop name="cat" type="category" page="{$category_current_page}" limit="2"} +

#LOOP_COUNT - #TITLE

+

Products :

+ +
+ + {assign var=this_product_getter value="product_`$ID`_page"} + + {assign var=product_current_page value={$smarty.get.$this_product_getter|default:1}} + +
    + {loop name="prod" type="product" category="#ID" page="{$product_current_page}" limit="2"} +
  • + #REF +
  • + {/loop} +
+ +
+ +

#TITLE page choice

+ {pageloop rel="prod"} + {if ${PAGE} != {$product_current_page}} + #PAGE + {else} + { #PAGE } + {/if} + {if {$PAGE} != {$LAST}} + - + {/if} + {/pageloop} + +{/loop} + +
+ +

categories page choice

+{pageloop rel="cat"} +{if ${PAGE} != {$category_current_page}} + #PAGE +{else} + { #PAGE } +{/if} +{if {$PAGE} != {$LAST}} + - +{/if} +{/pageloop} \ No newline at end of file