Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How can you set the compile path for a simple view?

Hi I have a module view for a CMS I am writing and for the individual modules, I am using simple view, however due to the method of deployment, the view folder is not writable, I use a folder outside the main path to put anything writable in, so my question is how can I set the ccompile path with simple view? See my code below:

$di->set('moduleView', function() use ($config) {
    $simpleView = new Phalcon\Mvc\View\Simple();
    $simpleView->setViewsDir('../modules/NewInToday/Frontend/Views/');
    $simpleView->registerEngines(array(".volt" => "Phalcon\Mvc\View\Engine\Volt"));
    return $simpleView;
}, true);


4.0k
Accepted
answer

Setting up the Volt Engine

$di->set('voltService', function($view, $di) {
    $volt = new Volt($view, $di);
    $volt->setOptions(array(
        "compiledPath" => "../app/compiled-templates/",
        "compiledExtension" => ".compiled"
    ));
    return $volt;
});

$di->set('moduleView', function() use ($config) {
    $simpleView = new Phalcon\Mvc\View\Simple();
    $simpleView->setViewsDir('../modules/NewInToday/Frontend/Views/');
    $simpleView->registerEngines(array(".volt" => "voltService"));
    return $simpleView;
}, true);

Cheers!

Setting up the Volt Engine

$di->set('voltService', function($view, $di) {
   $volt = new Volt($view, $di);
   $volt->setOptions(array(
       "compiledPath" => "../app/compiled-templates/",
       "compiledExtension" => ".compiled"
   ));
   return $volt;
});

$di->set('moduleView', function() use ($config) {
   $simpleView = new Phalcon\Mvc\View\Simple();
   $simpleView->setViewsDir('../modules/NewInToday/Frontend/Views/');
   $simpleView->registerEngines(array(".volt" => "voltService"));
   return $simpleView;
}, true);