Search code examples
phpmodel-view-controllerzend-viewzend-framework

Zend Framework is using html files as view script instead of phtml


We had a developer code for us, and he did it in php. When we were studying the code, we noticed that all the views have html as their extension instead of phtml. We checked by renaming a file to phtml, and it gives an error. What's amazing is that they have not done this in the app, they have done it at Zend Level.

IF I replace the zend framework in the library directory with a fresh download, the app stops working. saying that the view was not found

Does anyone know how they did this (modified ZF to search for html instead of phtml files)?

One more thing: all over the place, he's using a variable $this->baseURL (not $this->baseUrl() as provided by zF) which holds the base url. Its not a helper, I checked and can't seem to find the declaration anywhere in the code, but still magically it is available through all the controllers and views. How did they implement? I did a search through all the files, but nowhere is baseURL defined or the option baseURL written to AUTH, STORAGE, or anything. So how did he get to this? Modify the zf again?


Solution

  • They may have changed the Zend Layout class file Zend/Layout.php.

    You can check for protected $_viewSuffix = 'html'; instead of phtml which is the default.

    You can fix this by adding the following to your bootstrap so you can upgrade the Zend Framework files.

    protected function _initViewSuffix()
    {
        Zend_Layout::getMvcInstance()->setViewSuffix('html');
    }
    

    As for the $baseURL variable, this could have been set via a plugin, or action helper.

    If you get the view object you can do something like $view->baseURL = 'xxx'; to make it available. This can be done from a plugin or action helper.

    Hope that helps.