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

How to use volt instead of phtml in the view of example tutorial 1?I tried but it doesn't work. why?

Hi guys, I have a question: How to use volt instead of phtml in the view of example tutorial 1? https://docs.phalcon.io/en/latest/reference/tutorial.html#creating-a-project

Official phtml code is

tutorial/app/view/index/index.phtml

<?php

echo "<h1>Hello!</h1>";

echo Phalcon\Tag::linkTo("signup", "Sign Up Here!");

I tried to modify the sufix to volt and change the code as below. But it doesn' t work.

tutorial/app/view/index/index.volt


{{ content() }}
<h1>Hello!</h1>
{{ link_to("signup", "Sign Up Here!") }}

What more, I copied the asset from project invo to tutorial 1, the same hierarchical relationship as invo.

public
 -js
 -css
 -img
 -bootstrap
 -.htaccess
 -index.php

I just modified some css, such as <h1>. But it doesn' t work either.To me I think this file(tutorial/app/view/index.volt) controls the UI,right?

tutorial/app/view/index.volt

<!DOCTYPE html>
<html>
    <head>  
        <meta charset="utf-8">
        {{ get_title() }}
        {{ stylesheet_link('bootstrap/css/bootstrap.css') }}
        {{ stylesheet_link('bootstrap/css/bootstrap-responsive.css') }}
        {{ stylesheet_link('css/style.css') }}
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="Your invoices">
        <meta name="author" content="Phalcon Team">
    </head>
    <body>
        {{ content() }}
        {{ javascript_include('js/jquery.min.js') }}
        {{ javascript_include('bootstrap/js/bootstrap.js') }}
        {{ javascript_include('js/utils.js') }}
    </body>
</html>

invo project asset url https://github.com/phalcon/invo/tree/master/public

tutorial 1 url https://github.com/phalcon/tutorial



98.9k

Did you register the Volt engine on Phalcon\Mvc\View? https://github.com/phalcon/invo/blob/master/public/index.php#L67



98.9k

You can add to public/css/style.css the following:

h1 { color: red }


10.3k
edited Aug '14

No, it doesn't work.