We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

view->getRender() multiple calls

I have an app that is converting the html result from view->getRender() into another file format. It does this by looping over files in a separate View dir and then calls view->getRender() for each one, the problem I'm having is that view->getRender() is only working for the first view in the directory and returns string '' (length=0) for any subsequent view.

Sample code:

        $iterator = new \DirectoryIterator($viewDir);
        $view = clone $this->view;
        $view->setViewsDir($viewDir);
        foreach($iterator as $ff) {
            if ($ff->isFile()) {
                $html = $view->getRender('Documentation', $ff->getBasename('.volt'));
                var_dump($ff->getBasename());
                var_dump($html);
            }
        }

Any ideas?



13.4k
Accepted
answer

https://forum.phalcon.io/discussion/812/getrender-doesn-t-poduct-any-content-for-the-second-template- provided a fix, not sure why specifying a service for use as the .volt extension compiler causes this behaviour?