PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 2, 2022

[FIXED] How to set a layout for a particular controller action or view in yii?

 January 02, 2022     php, yii     No comments   

Issue

Well, this part is very important. I'm working on a project with YII. I faced a problem like, I was trying to set one of my action in controller with a layout. 1st of all, this action not even taking the default layout mentioned, where another action actionIndex() is working fine on the same controller. Then I tried for $this->layout='//layouts/new' in the controller even triend it on the view rendering to the controller. That's even not working. I checked whether it returns any $content to the layout new.php or not. But it's not even coming to new.php. die() is not working even if I put it on the 1st line of the layout. I need help on this.


Solution

 public function actionTest() {
        $this->layout = 'new';
        $this->render('test');

    }

create new layout in views/layouts folder.



Answered By - hemc4
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing