How to change load layout in Joomla view?

user1692333 picture user1692333 · Nov 14, 2012 · Viewed 9.7k times · Source

By default parent::display($tpl); loads components/com_my_component/views/my_component/tmpl/default.php, but in some cases i need to load other php file which is in the same folder near default.php (for example components/com_my_component/views/my_component/tmpl/lol.php). How to do this from view.html.php.

P.S.

Tried load loadTemplate and setLayout methods with no luck.

Answer

user1692333 picture user1692333 · Nov 14, 2012

Solved the problem by myself. Need to use the method setLayout and pay attention to the input syntax

$this->setLayout('dafault:lol');
parent::display($tpl);