We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to arrange the layout elements in controller Phalcon

Hi Phalcon group, I want to show files partial view in layout from Controller with precisely defined positions, please see my photo

please guide me how to be declared as above

edited Mar '16

And whats your problem exactly ? I dont sure how this is related to phalcon, its only css bro. Just in "base" template file make divs for left partial, center partial, right partial and heder where you will place them and their content will be your partials.



1.4k

And whats your problem exactly ? I dont sure how this is related to phalcon, its only css bro. Just in "base" template file make divs for left partial, center partial, right partial and heder where you will place them and their content will be your partials.

No. He/She want's to split one controller into 4 controllers.

You can only use one controller. And as @Jurigag said, you can split your view into parts/partials - see docs: https://docs.phalcon.io/en/latest/reference/volt.html#view-integration

The question is quite vague, but I hope this will help:

// controllers/Example.php
class ExampleController {
    public function someAction() {
        $this->view->tpl_header = 'header1';
        $this->view->tpl_left = 'left1';
        $this->view->tpl_center = 'center1';
        $this->view->tpl_right = 'right1';
        $this->view->data_center = [
            'some' => 'value',
        ];
    }
}
{# example/some.volt #}
<div class="header">
    {{ partial('partials/'~tpl_header) }}
</div>
<div style="float:left; width: 160px;">
    {{ partial('partials/'~tpl_left) }}
</div>
<div style="float:left; width: 400px;">
    {{ partial('partials/'~tpl_center, data_center) }}
</div>
<div style="float:left; width: 160px;">
    {{ partial('partials/'~tpl_right) }}
</div>
{# partials/header1.volt #}
<h1>My awesome project<h1>
{# partials/left1.volt #}
<ul>
    <li><a href="#">link1</a></li>
    <li><a href="#">link2</a></li>
</ul>
{# partials/center1.volt #}
My data: {{ some }}
{# partials/right1.volt #}
<img src="some_nice_image.jpg" />


26.3k
Accepted
answer
edited Mar '16

thank you for helping me, I have done this through a combination my class custom and partial

<div class="row"> <div class="md-col-6"> Postion 1: <?php $this->position->set('left')?> </div> <div class="md-col-6"> Postion 2: <?php $this->position->set('right')?> </div> </div>

And Position.php class I will set partial view

$view = $this->getDI()->get('view'); $view->partial(APP_PATH.'/public/themes/default/views/share/file');

currently experiencing a problem can not get Module name, controller name in file class Position.php