PHP code example of pdaleramirez / category-tree
1. Go to this page and download the library: Download pdaleramirez/category-tree library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pdaleramirez / category-tree example snippets
[
0 => [
'id' => '14'
'parentId' => 0
'title' => 'Dropdown 1'
'model' => 'craft\\elements\\Category'
'children' => [
0 => [
'id' => '15'
'parentId' => '14'
'title' => 'Dropdown 1.1'
'model' => 'craft\\elements\\Category'
'children' => [
0 => [
'id' => '22'
'parentId' => '15'
'title' => 'Dropdown 1.1.1'
'model' => 'craft\\elements\\Category'
]
1 => [
'id' => '23'
'parentId' => '15'
'title' => 'Dropdown 1.1.2'
'model' => 'craft\\elements\\Category'
]
2 => [
'id' => '24'
'parentId' => '15'
'title' => 'Dropdown 1.1.3'
'model' => 'craft\\elements\\Category'
]
]
]
1 => [
'id' => '13'
'parentId' => '14'
'title' => 'Dropdown 1.2'
'model' => 'craft\\elements\\Category'
]
2 => [
'id' => '11'
'parentId' => '14'
'title' => 'Dropdown 1.3'
'model' => 'craft\\elements\\Category'
]
]
]
1 => [
'id' => '17'
'parentId' => 0
'title' => 'Dropdown 2'
'model' => 'craft\\elements\\Category'
'children' => [
0 => [
'id' => '25'
'parentId' => '17'
'title' => 'Dropdown 2.1'
'model' => 'craft\\elements\\Category'
'children' => [
0 => [
'id' => '27'
'parentId' => '25'
'title' => 'Dropdown 2.1.1'
'model' => 'craft\\elements\\Category'
]
1 => [
'id' => '30'
'parentId' => '25'
'title' => 'Dropdown 2.1.2'
'model' => 'craft\\elements\\Category'
]
]
]
1 => [
'id' => '28'
'parentId' => '17'
'title' => 'Dropdown 2.2'
'model' => 'craft\\elements\\Category'
]
2 => [
'id' => '26'
'parentId' => '17'
'title' => 'Dropdown 2.3'
'model' => 'craft\\elements\\Category'
]
]
]
2 => [
'id' => '12'
'parentId' => 0
'title' => 'Dropdown 3'
'model' => 'craft\\elements\\Category'
'children' => [
0 => [
'id' => '16'
'parentId' => '12'
'title' => 'Dropdown 3.1'
'model' => 'craft\\elements\\Category'
]
1 => [
'id' => '29'
'parentId' => '12'
'title' => 'Dropdown 3.2'
'model' => 'craft\\elements\\Category'
]
]
]
]
{{ craft.categorytree.getList(1,{'base': '/category/',
'attribute': 'slug',
'class': 'category-tree'
}) }}