{"action":"created","issue":{"url":"https://api.github.com/repos/phalcon/cphalcon/issues/13050","repository_url":"https://api.github.com/repos/phalcon/cphalcon","labels_url":"https://api.github.com/repos/phalcon/cphalcon/issues/13050/labels{/name}","comments_url":"https://api.github.com/repos/phalcon/cphalcon/issues/13050/comments","events_url":"https://api.github.com/repos/phalcon/cphalcon/issues/13050/events","html_url":"https://github.com/phalcon/cphalcon/issues/13050","id":254596951,"number":13050,"title":"clustered template rendering","user":{"login":"svfnix","id":13026388,"avatar_url":"https://avatars2.githubusercontent.com/u/13026388?v=4","gravatar_id":"","url":"https://api.github.com/users/svfnix","html_url":"https://github.com/svfnix","followers_url":"https://api.github.com/users/svfnix/followers","following_url":"https://api.github.com/users/svfnix/following{/other_user}","gists_url":"https://api.github.com/users/svfnix/gists{/gist_id}","starred_url":"https://api.github.com/users/svfnix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svfnix/subscriptions","organizations_url":"https://api.github.com/users/svfnix/orgs","repos_url":"https://api.github.com/users/svfnix/repos","events_url":"https://api.github.com/users/svfnix/events{/privacy}","received_events_url":"https://api.github.com/users/svfnix/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2017-09-01T10:12:07Z","updated_at":"2017-09-01T11:03:13Z","closed_at":null,"author_association":"NONE","body":"I want to suggest to adding a new template rendering mechanism which i named CTR. \r\nit is very efficient and comfortable and usable\r\nif this is possible, please add it to view object\r\n\r\n### clustered template rendering\r\nin this mechanism every template has a phtml file and a directory beside that shapes a tree of parent-child[s] templates\r\n\r\nsomething like these :\r\n\r\n> views/fa.phtml\r\n> views/fa/admin.phtml\r\n> views/fa/admin/news.phtml\r\n> views/fa/admin/news/index.phtml\r\n> views/fa/admin/news/add.phtml\r\n> views/fa/admin/news/edit.phtml\r\n> views/fa/admin/blog.phtml\r\n> views/fa/admin/blog/index.phtml\r\n> views/fa/admin/blog/add.phtml\r\n> views/fa/admin/blog/edit.phtml\r\n\r\n> views/en.phtml\r\n> views/en/admin.phtml\r\n> views/en/admin/news.phtml\r\n> views/en/admin/news/index.phtml\r\n> views/en/admin/news/add.phtml\r\n> views/en/admin/news/edit.phtml\r\n> views/en/admin/blog.phtml\r\n> views/en/admin/blog/index.phtml\r\n> views/en/admin/blog/add.phtml\r\n> views/en/admin/blog/edit.phtml\r\n> ...\r\n\r\nin this onion like structure we have n layer and every inner layer will be wrapped by parent layer **Automatically**\r\n\r\nat the moment i've written a function which can render this kind of structure. i want to suggest this mechanism to be added to the core of phalcon.\r\n\r\n```php\r\nnamespace App;\r\n\r\nclass Controller extends \\Phalcon\\Mvc\\Controller\r\n{\r\n    protected function ctrRender(){\r\n        $args = func_get_args();\r\n        $args = explode('/', implode('/', $args));\r\n\r\n        $param = [];\r\n        if(is_array(end($args))) {\r\n            $param = array_pop($args);\r\n        }\r\n        while($args){\r\n            $this->view->render(implode('/', $args), $param);\r\n            array_pop($args);\r\n        }\r\n    }\r\n}\r\n```\r\nusage:\r\n```php\r\nclass IndexController extends \\App\\Controller\r\n{\r\n    public function indexAction()\r\n    {\r\n        $this->ctrRender('fa/admin/blog/add');\r\n        // or\r\n        $this->ctrRender('fa', 'admin', 'news', 'index');\r\n        // or\r\n        $this->ctrRender('en', 'admin', 'news', 'edit', [\r\n                'news' => $news\r\n        ]);\r\n\r\n        // there is no limit in number of layers\r\n        $this->ctrRender('en', 'admin', 'news', 'index', 'bla', 'bla', b'a', ...);\r\n    }\r\n}\r\n```\r\n\r\n```php\r\n// fa.phtml\r\n<div class=\"fa\">\r\n        <?= $this->getContent() ?>\r\n</div>\r\n```\r\n\r\n```php\r\n// fa/admin.phtml\r\n<div class=\"admin\">\r\n        <?= $this->getContent() ?>\r\n</div>\r\n```\r\n\r\n```php\r\n// fa/admin/news.phtml\r\n<div class=\"news\">\r\n        <?= $this->getContent() ?>\r\n</div>\r\n```\r\n\r\n```php\r\n// fa/admin/news/index.phtml\r\n<div class=\"index\">\r\n        <h1>hello there</h1>\r\n</div>\r\n```\r\n\r\n\r\n```php\r\n// result\r\n<div class=\"fa\">\r\n        <div class=\"admin\">\r\n                <div class=\"news\">\r\n                        <div class=\"index\">\r\n                                <h1>hello there</h1>\r\n                        </div>\r\n                </div>\r\n        </div>\r\n</div>\r\n```"},"comment":{"url":"https://api.github.com/repos/phalcon/cphalcon/issues/comments/326553243","html_url":"https://github.com/phalcon/cphalcon/issues/13050#issuecomment-326553243","issue_url":"https://api.github.com/repos/phalcon/cphalcon/issues/13050","id":326553243,"user":{"login":"Jurigag","id":10086991,"avatar_url":"https://avatars3.githubusercontent.com/u/10086991?v=4","gravatar_id":"","url":"https://api.github.com/users/Jurigag","html_url":"https://github.com/Jurigag","followers_url":"https://api.github.com/users/Jurigag/followers","following_url":"https://api.github.com/users/Jurigag/following{/other_user}","gists_url":"https://api.github.com/users/Jurigag/gists{/gist_id}","starred_url":"https://api.github.com/users/Jurigag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jurigag/subscriptions","organizations_url":"https://api.github.com/users/Jurigag/orgs","repos_url":"https://api.github.com/users/Jurigag/repos","events_url":"https://api.github.com/users/Jurigag/events{/privacy}","received_events_url":"https://api.github.com/users/Jurigag/received_events","type":"User","site_admin":false},"created_at":"2017-09-01T11:03:13Z","updated_at":"2017-09-01T11:03:13Z","author_association":"MEMBER","body":"You can just mix `{% extends %}` and hierarchical rendering and you will almost have what you want. Though i didn't test it."}}
{"actor":{"display_login":"Jurigag"}}