[NFR] Specify the path to the main layout and partials
Do, please, methods to specify a path to the main layout and partials of object View.
<?php
namespace Phalcon\Mvc;
class View extends \Phalcon\DI\Injectable
{
// ...
public function setLayoutsDir($layoutsDir)
{
$this->_layoutsDir = (string) $layoutsDir;
}
public function setPartialsDir($partialsDir)
{
$this->_partialsDir = (string) $partialsDir;
}
// ...
}
In his project I use a directory structure views:
/app/views - base path of views
/app/views/layouts/main.phtml - main layout of page
/app/views/partials/header.phtml - layout header of page
/app/views/partials/footer.phtml - layout footer of page
/app/views/contents/index.phtml - layout of IndexController
/app/views/contents/index/index.phtml - view of IndexController::indexAction
I had to write an extension for your class \Phalcon\Mvc\View
P.S. Sorry for my english ;)
That is interesting :)
Do you mind sharing your implementation in the incubator?
https://github.com/phalcon/incubator
I suggest following structure:
/app/views
/app/layouts/ // Layouts and Partials
/app/layouts/main.phtml
/app/layouts/header.phtml
/app/layouts/footer.phtml
/app/views/contents/index.phtml
/app/views/index.phtml`
This is a good option, but not /app/views/contents/index.phtml, and the /app/views/index/index.phtml
Only the directory layout I did a little bit differently:
/app/layouts/ - layouts and partials
/app/layouts/main.phtml - main layout of page
/app/layouts/main/header.phtml
/app/layouts/main/footer.phtml
/app/layouts/mobile.phtml - main layout of the mobile version
/app/layouts/mobile/header.phtml
/app/layouts/mobile/footer.phtml
<!-- /app/layouts/main.phtml -->
<!DOCTYPE html>
<html>
<body>
<?= $this->partial('main/header.phtml') ?>
<?= $this->content() ?>
<?= $this->partial('main/footer.phtml') ?>
</body>
</html>
I will try to write an extension for this option. Only standard class Phalcon\Mvc\View badly expands - continuous hard code :(
This was addressed in 0.8.0