3

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.

WinterCoder
  • 106
  • 1
  • 4

1 Answers1

2

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;
    }
);
James Fenwick
  • 2,190
  • 1
  • 20
  • 30
  • sorry for misunderstood but I use phtml for volt engine (but I dont write the all configuration). Real question is this, how can i remove all native php codes from volt interpreted page. I want to only use volt tags and remove all the php content. By the default; volt engine supports native php as I know. I try to use regex for remove php blocks but its uneffective solution. – WinterCoder Jan 26 '16 at 02:06
  • 1
    In that case you will probably have to go through each view and change them manually – James Fenwick Jan 26 '16 at 07:33