PHPackages                             yongtiger/yii2-bootstrap-tree - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. yongtiger/yii2-bootstrap-tree

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

yongtiger/yii2-bootstrap-tree
=============================

A bootstrap tree for both jonmiles bootstrap treeview 1.2.0 and 2.0.0 (https://github.com/jonmiles/bootstrap-treeview)

1.0.2(9y ago)212.6k↓100%MITPHPPHP &gt;=5.5

Since Apr 16Pushed 9y ago2 watchersCompare

[ Source](https://github.com/yongtiger/yii2-bootstrap-tree)[ Packagist](https://packagist.org/packages/yongtiger/yii2-bootstrap-tree)[ Docs](http://www.branbook.cc)[ RSS](/packages/yongtiger-yii2-bootstrap-tree/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (7)Used By (0)

yii2-bootstrap-tree release version 1.0.2 (typo)
================================================

[](#yii2-bootstrap-tree-release-version-102-typo)

A bootstrap tree for `jonmiles bootstrap treeview` BOTH `1.2.0` and `2.0.0` (). Forked and improved from [dmitry-suffi/yii-tree-widget](https://github.com/dmitry-suffi/yii-tree-widget) and [lesha724/yii2-bootstrap-tree](https://github.com/lesha724/yii2-bootstrap-tree).

[![Latest Stable Version](https://camo.githubusercontent.com/10e5c9a38d35ffe989cb00e62426aeb92cff9c5ea0ea607d0c4d8247e909fa54/68747470733a2f2f706f7365722e707567782e6f72672f796f6e6774696765722f796969322d626f6f7473747261702d747265652f762f737461626c65)](https://packagist.org/packages/yongtiger/yii2-bootstrap-tree)[![Total Downloads](https://camo.githubusercontent.com/8bbb8b1d71d284068ec7666fd0900ca0246cf1adf483a2951d1f1d5bcb2f84b3/68747470733a2f2f706f7365722e707567782e6f72672f796f6e6774696765722f796969322d626f6f7473747261702d747265652f646f776e6c6f616473)](https://packagist.org/packages/yongtiger/yii2-bootstrap-tree)[![Latest Unstable Version](https://camo.githubusercontent.com/d219a7278ca0a5f6d3c7d69e00e91cc437c961798be81dbbb6856795cfd74893/68747470733a2f2f706f7365722e707567782e6f72672f796f6e6774696765722f796969322d626f6f7473747261702d747265652f762f756e737461626c65)](https://packagist.org/packages/yongtiger/yii2-bootstrap-tree)[![License](https://camo.githubusercontent.com/51bea24c2cdccd281c96cbf8158379c522daed4013034b73de61f472e1aa14d6/68747470733a2f2f706f7365722e707567782e6f72672f796f6e6774696765722f796969322d626f6f7473747261702d747265652f6c6963656e7365)](https://packagist.org/packages/yongtiger/yii2-bootstrap-tree)

FEATURES
--------

[](#features)

- for `jonmiles bootstrap treeview` BOTH `1.2.0` and `2.0.0` ()
- automatically displaying selected nodes according to route/params (e.g. `id`) [![](docs/demo.png)](docs/demo.png)

DEPENDENCES
-----------

[](#dependences)

- `jonmiles bootstrap treeview 1.2.0` or `2.0.0` ()

INSTALLATION
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist yongtiger/yii2-bootstrap-tree "*"

```

or add

```
"yongtiger/yii2-bootstrap-tree": "*"
```

to the require section of your composer.json.

CONFIGURATION
-------------

[](#configuration)

USAGES
------

[](#usages)

### Example of `data.$items` structure ():

[](#example-of-dataitems-structure-httpsgithubcomjonmilesbootstrap-treeviewdata-structure)

```
$items = [
    [
        'text' => 'Node 1',                                 ///(needed!)
        'href' => ['site/index', id => 1],                  ///(optional) Note: `href` must be route array!
        'icon' => 'glyphicon glyphicon-stop',               ///(optional)
        'selectedIcon' => "glyphicon glyphicon-stop",       ///(optional)
        'selectable' => true,                               ///(optional)
        'state' => [                                        ///(optional)
            // 'checked' => true,
            // 'disabled' => true,
            // 'expanded' => true,
            // 'selected' => true,
        ],
        'tags' => ['available'],                            ///(optional)

        'visible' => true,                                  ///(optional) same as [yii\widgets\Menu::$visible]
        'encode' => true,                                   ///(optional) same as [yii\widgets\Menu::$encode]
        // ...
        'nodes' =>
        [
            ['text' => 'Node 1.1', 'href' => ['site/index', id => 2]],
            ['text' => 'Node 1.2', 'href' => ['site/index', id => 3]],
        ]
    ],
    [
        'text' => 'Node 2',
        'href' => ['site/index', id => 4],
        'nodes' => [
            ['text' => 'Node 2.1', 'href' => ['site/index', id => 5]],
            ['text' => 'Node 2.2', 'href' => ['site/index', id => 6]],
        ]
    ],
    // ...
];
```

```
echo \yongtiger\bootstraptree\widgets\BootstrapTree::widget([
    'options'=>[
        //https://github.com/jonmiles/bootstrap-treeview#options
        'data' => $items,                                   ///(needed!)
        'enableLinks' => true,                              ///(optional)
        'showTags' => true,                                 ///(optional)
        'levels' => 3,                                      ///(optional)
        'multiSelect' => true,  ///(optional, but when `selectParents` is true, you must also set this to true!)
    ],
    'htmlOptions' => [                                      ///(optional)
        'id' => 'treeview-tabs',
    ],
    'events'=>[	                                            ///(optional)
        //https://github.com/jonmiles/bootstrap-treeview#events
        'onNodeSelected'=>'function(event, data) {
            // Your logic goes here
            alert(data.text);
        }'
    ],

    ///(needed for using jonmiles bootstrap-treeview 2.0.0, must specify it as `{text}`)
    'textTemplate' => '{text}',

    ///(optional) Note: when it is true, you must also set `multiSelect` of the treeview widget options to true!
    'selectParents' => true,
]);
```

### Other usages are just same as [yii\\widgets\\Menu](http://www.yiiframework.com/doc-2.0/yii-widgets-menu.html).

[](#other-usages-are-just-same-as-yiiwidgetsmenu)

- `textTemplate` is same as [yii\\widgets\\Menu::labelTemplate](http://www.yiiframework.com/doc-2.0/yii-widgets-menu.html#$labelTemplate-detail)

    Note: for using `jonmiles bootstrap-treeview 2.0.0`, must specify it as `{text}`
- `encodeTexts` is same as [yii\\widgets\\Menu::encodeLabels](http://www.yiiframework.com/doc-2.0/yii-widgets-menu.html#$encodeLabels-detail)
- `selectNodes` is same as [yii\\widgets\\Menu::activateItems](http://www.yiiframework.com/doc-2.0/yii-widgets-menu.html#$activateItems-detail)
- `selectParents` is same as [yii\\widgets\\Menu::activateParents](http://www.yiiframework.com/doc-2.0/yii-widgets-menu.html#$activateParents-detail)

    Note: when it is true, you must also set `multiSelect` of the treeview widget options to true!
- `hideEmptyNodes` is same as [yii\\widgets\\Menu::hideEmptyItems](http://www.yiiframework.com/doc-2.0/yii-widgets-menu.html#$hideEmptyItems-detail)
- `route` is same as [yii\\widgets\\Menu::route](http://www.yiiframework.com/doc-2.0/yii-widgets-menu.html#$route-detail)
- `params` is same as [yii\\widgets\\Menu::params](http://www.yiiframework.com/doc-2.0/yii-widgets-menu.html#$params-detail)

NOTES
-----

[](#notes)

- `href` has been obsoleted in `jonmiles bootstrap-treeview 2.0.0`. You can specify `textTemplate` as `{text}` in the treeview widget options to generate the url of node.

DOCUMENTS
---------

[](#documents)

REFERENCES
----------

[](#references)

-
-

SEE ALSO
--------

[](#see-also)

TBD
---

[](#tbd)

[Development roadmap](docs/development-roadmap.md)
--------------------------------------------------

[](#development-roadmap)

LICENSE
-------

[](#license)

**yii2-bootstrap-tree** is released under the MIT license, see [LICENSE](https://opensource.org/licenses/MIT) file for details.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity62

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

6

Last Release

3306d ago

Major Versions

v0.0.2 → 1.0.02017-04-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/4419bd4781ece5b372f87972d5559c6a9ff305d8600fcf99409ce072922b9771?d=identicon)[yongtiger](/maintainers/yongtiger)

---

Tags

treeyii2extensionwidgetbootstraptreeview

### Embed Badge

![Health badge](/badges/yongtiger-yii2-bootstrap-tree/health.svg)

```
[![Health](https://phpackages.com/badges/yongtiger-yii2-bootstrap-tree/health.svg)](https://phpackages.com/packages/yongtiger-yii2-bootstrap-tree)
```

###  Alternatives

[nex/yii2-chosen

Bootstrap Chosen widget for Yii2

2796.6k](/packages/nex-yii2-chosen)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
