php8.5
Home/ Manual/ yaf / yaf_controller_abstract/ Yaf_Controller_Abstract::setViewpath

Yaf_Controller_Abstract::setViewpath

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Set the view path

Description

Yaf_Controller_Abstract::setViewpath(string $view_directory): bool|null

Sets the template directory of the view engine bound to this controller.

Parameters

view_directory

The directory that holds the view templates.

Return Values

Returns true on success, or false / null on failure.

Examples

Yaf_Controller_Abstract::setViewpath example

php
<?php
class ProductController extends Yaf_Controller_Abstract
{
    public function init() {
        // from now on templates of this controller are looked up
        // under application/themes/dark/views/
        $this->setViewpath(APPLICATION_PATH . "/themes/dark/views");
    }

    public function indexAction() {
        // renders application/themes/dark/views/product/index.phtml
        $this->display("product/index.phtml");
    }
}
?>

See Also

  • Yaf_Controller_Abstract::getViewpath

Source: reference/yaf/yaf_controller_abstract/setviewpath.xml · from the official PHP manual (php/doc-en)