Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit 1a6126d5 authored by Nicolas BEJEAN's avatar Nicolas BEJEAN
Browse files

Corrections de l'affichage du template

parent d87bd172
No related branches found
Tags v1.0.1
No related merge requests found
<?php <?php
namespace NicolasBejean\CategoryWidget\Block\Widget; namespace NicolasBejean\CategoryWidget\Block\Widget;
class CategoryWidget extends \Magento\Framework\View\Element\Template implements \Magento\Widget\Block\BlockInterface use Magento\Framework\View\Element\Template;
use Magento\Widget\Block\BlockInterface;
class CategoryWidget extends Template implements BlockInterface
{ {
/** /**
* Category helper * Category helper
...@@ -120,7 +123,10 @@ class CategoryWidget extends \Magento\Framework\View\Element\Template implements ...@@ -120,7 +123,10 @@ class CategoryWidget extends \Magento\Framework\View\Element\Template implements
*/ */
public function getTemplate() public function getTemplate()
{ {
return $this->getData('template'); if ($this->hasData('template')) {
$this->setTemplate($this->getData('template'));
}
return $this->_template;
} }
/** /**
......
...@@ -18,7 +18,7 @@ class CategoryList implements ArrayInterface ...@@ -18,7 +18,7 @@ class CategoryList implements ArrayInterface
public function getStoreCategories($sorted = false, $asCollection = false, $toLoad = true) public function getStoreCategories($sorted = false, $asCollection = false, $toLoad = true)
{ {
return $this->_categoryHelper->getStoreCategories($sorted , $asCollection, $toLoad); return $this->_categoryHelper->getStoreCategories($sorted, $asCollection, $toLoad);
} }
/* /*
...@@ -27,19 +27,15 @@ class CategoryList implements ArrayInterface ...@@ -27,19 +27,15 @@ class CategoryList implements ArrayInterface
*/ */
public function toOptionArray() public function toOptionArray()
{ {
$arr = $this->toArray(); $arr = $this->toArray();
$ret = []; $ret = [];
foreach ($arr as $key => $value) foreach ($arr as $key => $value) :
{
$ret[] = [ $ret[] = [
'value' => $key, 'value' => $key,
'label' => $value 'label' => $value
]; ];
} endforeach;
return $ret; return $ret;
} }
...@@ -50,19 +46,14 @@ class CategoryList implements ArrayInterface ...@@ -50,19 +46,14 @@ class CategoryList implements ArrayInterface
*/ */
public function toArray() public function toArray()
{ {
/* /* Le paramètre asCollection permet à true d'afficher le second niveau des catégories */
* Le paramètre asCollection permet à true d'afficher le second niveau des catégories
*/
$categories = $this->getStoreCategories(false,true,true); $categories = $this->getStoreCategories(false,true,true);
$categoryList = array(); $categoryList = array();
foreach ($categories as $category){ foreach ($categories as $category) :
$categoryList[$category->getEntityId()] = __($category->getName()); $categoryList[$category->getEntityId()] = __($category->getName());
} endforeach;
return $categoryList; return $categoryList;
} }
} }
\ No newline at end of file
...@@ -2,35 +2,35 @@ ...@@ -2,35 +2,35 @@
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd"> xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd">
<widget id="nicolasbejean_categorywidget" class="NicolasBejean\CategoryWidget\Block\Widget\CategoryWidget"> <widget id="nicolasbejean_categorywidget" class="NicolasBejean\CategoryWidget\Block\Widget\CategoryWidget">
<label translate="true">widget_label</label> <label>widget_label</label>
<description translate="true">widget_description</description> <description>widget_description</description>
<parameters> <parameters>
<parameter name="widget_title" xsi:type="text" visible="true" sort_order="1"> <parameter name="widget_title" xsi:type="text" visible="true" sort_order="1">
<label translate="true">widget_title</label> <label>widget_title</label>
</parameter> </parameter>
<parameter name="widget_content" xsi:type="text" visible="true" sort_order="2"> <parameter name="widget_content" xsi:type="text" visible="true" sort_order="2">
<label translate="true">widget_content</label> <label>widget_content</label>
</parameter> </parameter>
<parameter name="category_selection" xsi:type="multiselect" visible="true" sort_order="3" source_model="NicolasBejean\CategoryWidget\Model\Config\Source\CategoryList"> <parameter name="category_selection" xsi:type="multiselect" visible="true" sort_order="3" source_model="NicolasBejean\CategoryWidget\Model\Config\Source\CategoryList">
<label translate="true">category_selection</label> <label>category_selection</label>
<description translate="true">category_selection_description</description> <description>category_selection_description</description>
</parameter> </parameter>
<parameter name="category_image_width" xsi:type="text" visible="true" sort_order="4"> <parameter name="category_image_width" xsi:type="text" visible="true" sort_order="4">
<label translate="true">category_image_width</label> <label>category_image_width</label>
<description translate="true">category_image_width_description</description> <description>category_image_width_description</description>
</parameter> </parameter>
<parameter name="category_image_height" xsi:type="text" visible="true" sort_order="5"> <parameter name="category_image_height" xsi:type="text" visible="true" sort_order="5">
<label translate="true">category_image_height</label> <label>category_image_height</label>
<description translate="true">category_image_height_description</description> <description>category_image_height_description</description>
</parameter> </parameter>
<parameter name="template" xsi:type="select" required="true" visible="true" sort_order="6"> <parameter name="template" xsi:type="select" required="true" visible="true" sort_order="6">
<label translate="true">template</label> <label>template</label>
<options> <options>
<option name="img_background" value="widget/category_widget_img_background.phtml" selected="true"> <option name="img_background" value="widget/category_widget_img_background.phtml" selected="true">
<label translate="true">default_template</label> <label>default_template</label>
</option> </option>
<option name="default" value="widget/category_widget.phtml"> <option name="default" value="widget/category_widget.phtml">
<label translate="true">other_template</label> <label>other_template</label>
</option> </option>
</options> </options>
</parameter> </parameter>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment