Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# CATEGORY WIDGET
Permet d'afficher une catégorie ou une liste de catégories avec leur image.
## Variables
- widget_title (setWidgetTitle) : Optionnel : Titre H2 du widget
- widget_content (setWidgetContent) : Optionnel : Contenu texte servant à insérer une description dans le widget
- category_selection (setCategorySelection): Obligatoire : ID de la catégorie à afficher. Pour en afficher plusieurs 3,6
- model (setModel) : Obligatoire : Permet de sélectionner le template de rendu
## Exemples d'intégration
Dans un fichier layout (XML) :
```xml
<block class="NicolasBejean\CategoryWidget\Block\Widget\CategoryWidget">
<arguments>
<argument name="category_selection" xsi:type="string">3</argument>
<argument name="model" xsi:type="string">widget/category_widget_img_background.phtml</argument>
</arguments>
</block>
```
Dans un fichier de template (PHTML) :
```php
<?php
echo $this ->getLayout()
->createBlock("NicolasBejean\CategoryWidget\Block\Widget\CategoryWidget")
->setCategorySelection("6")
->setModel("widget/category_widget.phtml")
->toHtml();
?>
```
Dans le backoffice :
```html
{{widget type="NicolasBejean\CategoryWidget\Block\Widget\CategoryWidget" widget_title="titre" widget_content="tag" category_selection="3" model="widget/category_widget_img_background.phtml"}}
```
## Structure LESS
Le fichier LESS doit être créé dans le dossier Category_Widget/web/css/source/_categoryWidget
```less
.category-widget {
.content-heading {
h2.title {}
p.content {}
}
.categories {
a.category {
img {}
span {}
}
}
}
```
## Source
https://github.com/Programmingatkstark/Magento-2-Category-with-image-widget