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

Not extending my layout


<?php
class UserController extends ControllerBase
{
    public function initialize(){
        Tag::setTitle('User');
        $this->view->setLayout('user');
        parent::initialize();
    }
    public function indexAction(){
        echo"Hello user";
    }
    public function goodbyeAction(){
        echo"goodbye";
    }
}

when I execute indexaction it uses my user layout which displays the code on my browser

<section class="container">
        <div class="row">
                    <div class="col-md-12"> 

                        <p>hello user  </p>

                 </div>
         </div>
</section>

when I execute goodbyeaction it just simply shows "goodbye" when I view source. What I want is it also uses the user layout just like what the indexaction does.



58.4k

Hello

Can you upload index user layout ?

edited Jul '14
<section class="container">
    <div class="row">
        <div class="col-md-12">             
               {{ content() }}      
        </div>
    </div>
</section>
edited Jul '14

You can download my project if you want

https://github.com/stevenpilagan/phalconrepo.git



58.4k
Accepted
answer
edited Jul '14

Hey

You must to create goodbye.volt in views/user dictionary then insert your html code want to used.

edited Jul '14

Is it not possible in phalcon that I can use only one view layout in one controller that has many method? so that i will not always creating view or volt for each method.

edited Jul '14

Thanks for that =D, anyway since I'm just new to Phalcon it was hard to me to integrate or get the idea of your code on what I want to do on my test project. Can you explain further your code on how you achieve the problem that I want to solve. Sorry for my english I'm not that fluent yet.