Placer
ΠΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ Π²ΠΈΠ΄ΠΆΠ΅ΡΠΎΠ² Π² ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΠΈ, Π²ΡΠ²ΠΎΠ΄ ΡΠ΅Π½Π΄Π΅ΡΠΈΠ½Π³ ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΠΉ Π² ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Π½ΡΡ
ΠΌΠ΅ΡΡΠ°Ρ
ΡΠ°Π±Π»ΠΎΠ½Π°, (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist padavvan/yii2-placer "*"
or add, (*4)
"padavvan/yii2-placer": "*"
to the require section of your composer.json
file., (*5)
Usage
Once the extension is installed, simply use it in your code by :, (*6)
<?php
use padavvan\placer\Portlet;
use padavvan\placer\Collection;
use padavvan\placer\RouteDependency;
$portlet1 = new Portlet(['name' => 'portlet1', 'content' => '#1 Portlet']);
$portlet2 = new Portlet(['name' => 'portlet2', 'content' => '#2 Portlet']);
$portlet2->wrap('section', ['class' => 'portlet']);
$portlet3 = new Portlet(['name' => 'portlet3', 'content' => '#3 Portlet']);
// main collection
$placer = new Collection('placer');
$subTop = Collection::create(['name' => 'subTop']);
$subTop
->push($portlet1)
->push($portlet2)
->wrap('div', ['class' => 'well']);
$top = new Collection(['name' => 'top', 'tag' => 'section']);
$top->push($portlet3);
$top->push($subTop);
$bottom = new Collection(['name' => 'bottom', 'tag' => 'div', 'options' => ['class' => 'footer']]);
$bottom->dependency = [
// view on site/about, site/info, etc
new RouteDependency('/site/*'),
// and not view on site/contacts
new RouteDependency('/site/contacts', true)
];
$bottom->push($portlet1);
$placer->push($top);
$placer->push($bottom);
echo $placer->render();
// or
echo $placer->top->render();
echo $placer->bottom->render();