Git Product home page Git Product logo

yii2-placer's Introduction

Placer

Добавление виджетов в коллекции, вывод рендеринг коллекций в определенных местах шаблона

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist padavvan/yii2-placer "*"

or add

"padavvan/yii2-placer": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

<?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();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.