0

I'm having a strange issue with Yii and a theme. I set it in config/main.php like:

'theme'=>'themeName',

as usual. But when I try to render a view, it is rendered as is, without any layout, as if I called:

$this->renderPartial 

I double check that I don't call for renderPartial, the themes seem to be equal to all the others theme I've done. What can be this issue about?

Thank's for any help, I'm going out of mind on this...

teone
  • 2,153
  • 3
  • 25
  • 49
  • may you capture screenshot your project structure and tell me know the view where the above line came from? – Telvin Nguyen Aug 07 '13 at 13:56
  • Sorry guys... I found that I had a really stupid error in the layout, like a missing ";" or something like that and errors where not enabled on the server... – teone Aug 26 '13 at 07:09

1 Answers1

0

Here is the structure and syntax that you should have to check

-yiiroot
-!-!protected
-!-!-!controllers
-!-!-!-!TestController.php 
-!-!themes
-!-!-!themeName (it was the one that you have set on config file)
-!-!-!-!views
-!-!-!-!-!layouts
-!-!-!-!-!-!main.php // It would be default what if public $layout has not been overwriten or the layout file which has been set was not found     
-!-!-!-!-!test
-!-!-!-!-!-!viewName.php 

On controller TestController

  • public $layout is main as default or is overwritten there

  • in actionIndex you set $this->render('viewName');

If you rendered your page by method renderPartial() directly in controller, you would not get the layout template for sure

render() is commonly used to render a view that corresponds to what a user sees as a "page" in your application. It first renders the view you have specified and then renders the layout for the current controller action (if applicable), placing the result of the first render into the layout. It then performs output processing (which at this time means automatically inserting any necessary tags and updating dynamic content) and finally outputs the result.

renderPartial() is commonly used to render a "piece" of a page. The main difference from render() is that this method does not place the results of the render in a layout. By default it also does not perform output processing, but you can override this behavior using the $processOutput parameter.

renderFile() is a low-level method that does the grunt work of rendering: it extracts the data variables in the current scope and then runs the view code. The other two methods internally call this one, but you should practically never need to call it yourself. If you do, keep in mind that you need to pass in a file path (not a view path).

Reference: Yii difference between rendering functions

Community
  • 1
  • 1
Telvin Nguyen
  • 3,569
  • 4
  • 25
  • 39