Module widget rendering before layout

Hi, guys,

I have a core module which has a login portlet. In the user controller I’ve got the action Login, which renders a view that contains the code to insert the core.components.login portlet in the page.

Portlet works fine, but it gets rendered outside the main layout.

As I’m using a theme, I’ve created a folder called LoginPortlet to customize the look of the loginPortlet view.




| |_core

|   |_controllers

|   | UserController.php

|   |

|   |_components

|   | LoginPortlet.php

|   | |_views

|   |   loginPortlet.php

|   |

|   |_views

|   | |_user

|   |   login.php   //this calls  $this->widget(core.components.LoginPortlet);


| |_custom

|   |_views

|     |_LoginPortlet

|       loginPortlet.php   //its ok, renders this view instead of the one in core module

Curiously, in localhost the portlet is rendered in the right place (inside the layout).

The resultant HTML is this: (plz use up-to-dated browser)

I’ve tried removing the code $this->widget from login.php view and the content is rendered in the right place.

The problem seems to appear whenever I call the portlet login inside the view. Other widgets are working very fine.

Could somebody please give me a hint?

Thank you very much


I think the widget is not using output buffering and so is sending output directly.

Take a look at the third parameter to widget(), ‘captureOutput’:

Something like this may solve the problem you’re seeing:

echo $this->widget('portletwidget', array(), true);

Thanks, Rob,

I’ve tried a lot of things and in the end, I think that the view file had wrong encoding or something like this, because creating a new loginPortlet.php view and copying the content of the old view inside it solved the problem.

It works now! :)

Thanks again for your time!