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.
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
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
]);
}