3
votes

How can i remove php code blocks from volt template file, which has .phtml extension?

forexample:

<!-- must to be remove -->
<h1><?=$tutorial?><h1>
<!-- //remove area -->

<!-- must to be stay  -->
<h1> {{tutorial}} </h1>
<!-- //must to be stay  -->

Note: i use phalcon's last version.

1

1 Answers

2
votes

If the extension is .phtml you are using the PHP template engine.

You will have to change your DI view config to include the Volt engine. Volt and PHP engines can be used side by side and will workout which to use based on the extension.

https://docs.phalconphp.com/en/latest/reference/volt.html

<?php

use Phalcon\Mvc\View;

// Registering Volt as template engine
$di->set(
    'view',
    function () {

        $view = new View();

        $view->setViewsDir('../app/views/');

        $view->registerEngines(
            array(
                ".phtml" => 'Phalcon\Mvc\View\Engine\Php',
                ".volt" => 'Phalcon\Mvc\View\Engine\Volt'
            )
        );

        return $view;
    }
);