[CakePHP]How to get View file name in element or layout

[cakephp 1.3.3]
I introduce how to get to know view name in element or layout that is specified by $this->render in controller.

For example, with the contact form, as seen below, many times with one action the view is specifed.

[php]
function contact() {
//first view or return selected
if (!empty($this->params[‘form’][‘return’]) || empty($this->data)) {
/* getting data required by form process */
}
//confirm view or error view
elseif (!empty($this->params[‘form’][‘confirm’])) {
/* validating process */
$this->render(‘contact_confirm’);
}
//finishing
else {
/* saving data process */
$this->render(‘contact_done’);
}
}
[/php]

But depending on the value of the view, there are times when I want to change the operation of element or layout.

At that time, if you render method override the app_controller, from the element or layout in $this->params[‘view’] you can subtract the value and it’s convenient.

[php]
function render($action = null, $layout = null, $file = null) {
if ($action !== null) {
$view = Inflector::underscore($action);
}
else {
$view = Inflector::underscore($this->action);
}
$this->params[‘view’] = $view;

if (!$controller = $this->params[‘controller’]) {
return false;
}
return parent::render($action, $layout, $file);
}
[/php]