PHPackages                             howardeagle/yii2-inline-widgets-behavior - 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. [Templating &amp; Views](/categories/templating)
4. /
5. howardeagle/yii2-inline-widgets-behavior

ActiveYii2-extension[Templating &amp; Views](/categories/templating)

howardeagle/yii2-inline-widgets-behavior
========================================

Allows to render widgets in page content in Yii2 Framework based projects

31.5k3[1 issues](https://github.com/outOFFspace/yii2-inline-widgets-behavior/issues)1PHP

Since Jan 26Pushed 8y ago3 watchersCompare

[ Source](https://github.com/outOFFspace/yii2-inline-widgets-behavior)[ Packagist](https://packagist.org/packages/howardeagle/yii2-inline-widgets-behavior)[ RSS](/packages/howardeagle-yii2-inline-widgets-behavior/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (1)

InlineWidgetsBehavior
=====================

[](#inlinewidgetsbehavior)

Allows to render widgets in page content in Yii2 Framework based projects

- [Extension](http://www.yiiframework.com/extension/inline-widget-behavior)

Install
-------

[](#install)

Either run

```
$ php composer.phar require --prefer-dist outOFFspace/Yii2-inline-widgets-behavior "*"

```

or add

```
"outOFFspace/Yii2-inline-widgets-behavior": "*"
~~~
to the `require` section of your `composer.json file`.

Usage example
-------------

### Add a allowed widgets list into `config/main.php`:

```php
return [
    // ...
    'params' => [
         // ...
        'runtimeWidgets'=> [
            'common\widgets\LastPosts',
        ]
    ]
]
```

### Create widgets:

```php
class LastPostsWidget extends Widget
{
    public $tpl = 'default';

    public function run()
    {
        $posts = Post::find()->published()->all();
        return $this->render('LastPosts/' . $this->tpl, [
            'posts' => $posts,
        ]);
    }
}
```

### Attach the behavior to a main controller:

```php
use howard\behaviors\iwb\InlineWidgetsBehavior;

class DefaultController extends Controller
{
    public function behaviors()
    {
        return [
            'InlineWidgetsBehavior' => [
                'class'=> InlineWidgetsBehavior::className(),
                'namespace'=> 'common\components\widgets', // default namespace (optional)
                'widgets'=> \Yii::$app->params['runtimeWidgets'],
                'startBlock'=> '[*',
                'endBlock'=> '*]',
             ],
        ];
    }
}
```

### You can define a global classname suffix like 'Widget':

```php
class DefaultController extends Controller
{
    public function behaviors()
    {
        return [
            'InlineWidgetsBehavior' => [
                'class' => InlineWidgetsBehavior::className(),
                'widgets' => \Yii::$app->params['runtimeWidgets'],
                'classSuffix' => 'Widget',
             ],
        ];
    }
}
```

for using short names 'LastPosts' instead of 'LastPostsWidget' :

```php
return [
    // ...
    'params' => [
         // ...
        'runtimeWidgets' => [
            'ContactsForm',
            'Comments',
            'common\widgets\LastPosts',
        ]
    ]
}
```

For insert widgets in content you can use string of this format in your text:
~~~
[|=[;=]]
~~~

For rendering widgets in any View you must call `Controller::decodeWidgets()` method for model HTML content.

### For example:

```php

```

to have an access to the model from widgets just specify the 'model' variable in `Controller::decodeWidgets()` method:

```php

```

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/df29bb8820123688fe990084337dfffcefdf0af15cea1a68a16113ed9fab52d9?d=identicon)[outOFFspace](/maintainers/outOFFspace)

---

Top Contributors

[![ElisDN](https://avatars.githubusercontent.com/u/1673552?v=4)](https://github.com/ElisDN "ElisDN (32 commits)")[![outOFFspace](https://avatars.githubusercontent.com/u/3662421?v=4)](https://github.com/outOFFspace "outOFFspace (27 commits)")[![demogorgorn](https://avatars.githubusercontent.com/u/7351565?v=4)](https://github.com/demogorgorn "demogorgorn (5 commits)")[![uchenic](https://avatars.githubusercontent.com/u/8637701?v=4)](https://github.com/uchenic "uchenic (1 commits)")

### Embed Badge

![Health badge](/badges/howardeagle-yii2-inline-widgets-behavior/health.svg)

```
[![Health](https://phpackages.com/badges/howardeagle-yii2-inline-widgets-behavior/health.svg)](https://phpackages.com/packages/howardeagle-yii2-inline-widgets-behavior)
```

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

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