refactor Loop Category
This commit is contained in:
@@ -26,6 +26,8 @@ namespace Thelia\Core\Template\Loop;
|
|||||||
|
|
||||||
|
|
||||||
use Thelia\Tpex\Element\Loop\BaseLoop;
|
use Thelia\Tpex\Element\Loop\BaseLoop;
|
||||||
|
use Thelia\Tpex\Element\Loop\LoopResult;
|
||||||
|
use Thelia\Tpex\Element\Loop\LoopResultRow;
|
||||||
use Thelia\Model\CategoryQuery;
|
use Thelia\Model\CategoryQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,10 +94,9 @@ class Category extends BaseLoop {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param string $text
|
* @return \Thelia\Tpex\Element\Loop\LoopResult
|
||||||
* @return mixed|string
|
|
||||||
*/
|
*/
|
||||||
public function exec($text)
|
public function exec()
|
||||||
{
|
{
|
||||||
$search = CategoryQuery::create();
|
$search = CategoryQuery::create();
|
||||||
|
|
||||||
@@ -157,25 +158,27 @@ class Category extends BaseLoop {
|
|||||||
|
|
||||||
$categories = $search->find();
|
$categories = $search->find();
|
||||||
|
|
||||||
$res = "";
|
$loopResult = new LoopResult();
|
||||||
|
|
||||||
foreach ($categories as $category) {
|
foreach ($categories as $category) {
|
||||||
|
|
||||||
if ($this->not_empty && $category->countAllProducts() == 0) continue;
|
if ($this->not_empty && $category->countAllProducts() == 0) continue;
|
||||||
|
|
||||||
$temp = str_replace("#TITLE", $category->getTitle(), $text);
|
$loopResultRow = new LoopResultRow();
|
||||||
$temp = str_replace("#CHAPO", $category->getChapo(), $temp);
|
$loopResultRow->set("TITLE",$category->getTitle());
|
||||||
$temp = str_replace("#DESCRIPTION", $category->getDescription(), $temp);
|
$loopResultRow->set("CHAPO", $category->getChapo());
|
||||||
$temp = str_replace("#POSTSCRIPTUM", $category->getPostscriptum(), $temp);
|
$loopResultRow->set("DESCRIPTION", $category->getDescription());
|
||||||
$temp = str_replace("#PARENT", $category->getParent(), $temp);
|
$loopResultRow->set("POSTSCRIPTUM", $category->getPostscriptum());
|
||||||
$temp = str_replace("#ID", $category->getId(), $temp);
|
$loopResultRow->set("PARENT", $category->getParent());
|
||||||
$temp = str_replace("#URL", $category->getUrl(), $temp);
|
$loopResultRow->set("ID", $category->getId());
|
||||||
$temp = str_replace("#LINK", $category->getLink(), $temp);
|
$loopResultRow->set("URL", $category->getUrl());
|
||||||
$temp = str_replace("#NB_CHILD", $category->countChild(), $temp);
|
$loopResultRow->set("LINK", $category->getLink());
|
||||||
$res .= $temp;
|
$loopResultRow->set("NB_CHILD", $category->countChild());
|
||||||
|
|
||||||
|
$loopResult->addRow($loopResultRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $loopResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Submodule core/lib/Thelia/Tpex updated: 8c4ab84562...9a02145f18
@@ -6,7 +6,6 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div>TODO write content<br />
|
<div>TODO write content<br />
|
||||||
|
|
||||||
<THELIA_cat type="category">
|
<THELIA_cat type="category">
|
||||||
#__COUNT__ - #TITLE <br />
|
#__COUNT__ - #TITLE <br />
|
||||||
nb child : #NB_CHILD <br /><br />
|
nb child : #NB_CHILD <br /><br />
|
||||||
|
|||||||
Reference in New Issue
Block a user