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

How to get name layout when use pick view?

I use database to set layout as:

public function indexAction()
{
    //$layout = get layout from database
    //$this->view->pick(layout);
    //AS...
    $this->view->pick('index/testPickView');
}

When var_dump $this->view I see:

["_pickView":protected]=>
  array(2) {
    [0]=>
    string(18) "index/testPickView"
    [1]=>
    string(5) "index"
  }

I want get : "index/testPickView" to check override layout from template on

/**
* Before render view
*
* @param PEvent $event
* @param PView $view
*/
public function beforeRender(PEvent $event, PView $view){
   //I want get : "index/testPickView" in here.
}

Thanks!

You can pass an array there:

$this->view->pick(["index", "testPickView"]);
edited Aug '15

:( I want get pick view name as: $viewLayout = $view->getPickView(..)

//I register view:beforeRender in DI VIEW: $eventsManager->attach('view:beforeRender', ...);
//And this is view beforeRender function

use Phalcon\Events\Event as PEvent;
use Phalcon\Mvc\View as PView;

class ZFrontTemplate
{
  public function beforeRender(PEvent $event, PView $view){
     //I want get : "index/testPickView" in here.
     //Example: $viewLayout = $view->getPickView(..)
  }
}

You can pass an array there:

$this->view->pick(["index", "testPickView"]);