From 5da11c253ef693d14ea76d5b06b01032b35fa93b Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 8 Jul 2013 10:57:49 +0200 Subject: [PATCH 1/3] fix propel namespaces --- core/lib/Thelia/Config/DatabaseConfiguration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Config/DatabaseConfiguration.php b/core/lib/Thelia/Config/DatabaseConfiguration.php index fcbe7e9e0..376c16609 100755 --- a/core/lib/Thelia/Config/DatabaseConfiguration.php +++ b/core/lib/Thelia/Config/DatabaseConfiguration.php @@ -60,7 +60,7 @@ class DatabaseConfiguration implements ConfigurationInterface ->cannotBeEmpty() ->end() ->scalarNode("classname") - ->defaultValue("Propel\Runtime\Connection\PropelPDO") + ->defaultValue("\Propel\Runtime\Connection\PropelPDO") ->end() ->end() ->end() From a06771bea605a7aed25e62fecf2f0b2429a895ff Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 8 Jul 2013 11:43:23 +0200 Subject: [PATCH 2/3] extends Symfony Request --- .../Thelia/Core/HttpFoundation/Request.php | 22 +++++++++++++++++++ .../{ => HttpFoundation}/Session/Session.php | 2 +- core/lib/Thelia/Core/TheliaHttpKernel.php | 2 +- web/index.php | 2 +- web/index_dev.php | 2 +- 5 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 core/lib/Thelia/Core/HttpFoundation/Request.php rename core/lib/Thelia/Core/{ => HttpFoundation}/Session/Session.php (97%) diff --git a/core/lib/Thelia/Core/HttpFoundation/Request.php b/core/lib/Thelia/Core/HttpFoundation/Request.php new file mode 100644 index 000000000..e2ed963d0 --- /dev/null +++ b/core/lib/Thelia/Core/HttpFoundation/Request.php @@ -0,0 +1,22 @@ +get("product_id"); + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php similarity index 97% rename from core/lib/Thelia/Core/Session/Session.php rename to core/lib/Thelia/Core/HttpFoundation/Session/Session.php index d9074cd20..4bd079685 100644 --- a/core/lib/Thelia/Core/Session/Session.php +++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php @@ -21,7 +21,7 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Session; +namespace Thelia\Core\HttpFoundation\Session; use Symfony\Component\HttpFoundation\Session\Session as BaseSession; diff --git a/core/lib/Thelia/Core/TheliaHttpKernel.php b/core/lib/Thelia/Core/TheliaHttpKernel.php index 445ebd1fa..1b053d9de 100755 --- a/core/lib/Thelia/Core/TheliaHttpKernel.php +++ b/core/lib/Thelia/Core/TheliaHttpKernel.php @@ -196,7 +196,7 @@ class TheliaHttpKernel extends HttpKernel $storage->setOptions(json_decode(Model\ConfigQuery::read("session_config.config"))); } - $session = new \Thelia\Core\Session\Session($storage); + $session = new \Thelia\Core\HttpFoundation\Session\Session($storage); $session->start(); $request->setSession($session); diff --git a/web/index.php b/web/index.php index db8d8a51d..4d50cc633 100755 --- a/web/index.php +++ b/web/index.php @@ -1,6 +1,6 @@ Date: Mon, 8 Jul 2013 11:52:10 +0200 Subject: [PATCH 3/3] 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