igogo5yo / yii2-render-many
Yii Framework 2 extension for render many views in one action (best solution for landing pages or pages with many content blocks)
Installs: 36
Dependents: 0
Suggesters: 0
Security: 0
Stars: 13
Watchers: 4
Forks: 2
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-11-07 00:43:04 UTC
README
Yii Framework 2 extension for render many views in one action (best solution for landing pages or pages with many content blocks)
Please submit issue reports and pull requests to the main repository. For license information check the LICENSE-file.
Installation
The preferred way to install this extension is through composer.
Either run
php composer require --prefer-dist igogo5yo/yii2-render-many
or add
"igogo5yo/yii2-render-many": ">=1.0"
to your composer.json
file
Example
use trait
... class MyController extends Controller { use igogo5yo\rendermany\RenderMany; public function actionIndex() { return $this->renderMany([ 'sliderSection' => [ 'slides' => ['img1.jpg', 'img3.jpg', 'img3.jpg'] ], 'contentSection' => [ 'title' => 'My post', 'description' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry...', ], 'partnersSection' => [ 'partners' => [ ['link' => '#', 'name' => 'partner 1'], ['link' => '#', 'name' => 'partner 2'], ['link' => '#', 'name' => 'partner 3'], ] ], 'footer' //without passing variables ]); } }
or extend your controller
class MyController extends igogo5yo\rendermany\Controller { public function actionIndex() { return $this->renderMany([ 'sliderSection' => [ 'slides' => ['img1.jpg', 'img3.jpg', 'img3.jpg'] ], 'contentSection' => [ 'title' => 'My post', 'description' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry...', ], 'partnersSection' => [ 'partners' => [ ['link' => '#', 'name' => 'partner 1'], ['link' => '#', 'name' => 'partner 2'], ['link' => '#', 'name' => 'partner 3'], ] ], 'footer' //without passing variables ]); } }
also you can use partial rendering
public function actionIndex() { return $this->renderMany([ 'sliderSection' => [ 'slides' => ['img1.jpg', 'img3.jpg', 'img3.jpg'] ], 'wrapper' => [ 'innerRenders' => $this->renderManyPartial([ 'innerView1' => [ 'param1' => 'some data 1'. 'param2' => 'some data 2' ], 'innerView2' //without passing variables ]) ], 'footer' //without passing variables ]); }