The volt engine in phalcon does not work.

Source: Internet
Author: User
The multi-module project generated by the volt engine does not work. js and css load does not respond, and partials does not work well. the view cannot be output. does it seem that the volt engine is not successfully registered or is it another reason? Ps: but comes with an engine. Files suffixed with. phtml can be introduced to JavaScript files according to the manual...

The multi-module project generated by the volt engine does not work. js and css load does not respond, and partials does not work well. the view cannot be output. does it seem that the volt engine is not successfully registered or is it another reason?

Ps: but comes with an engine. Files suffixed with. phtml can be imported into js, css, and partials files according to the manual. On the basis of the above, after changing the suffix to the. volt format, what else do I need to change?

Directory structure

The following is part of the code in config/services. php, which is automatically generated when a project is generated.

$di->setShared('view', function () use ($config) {    $view = new View();    $view->setViewsDir($config->application->viewsDir);    $view->registerEngines(array(        '.volt' => function ($view, $di) use ($config) {            $volt = new VoltEngine($view, $di);            $volt->setOptions(array(                'compiledPath' => $config->application->cacheDir,                'compiledSeparator' => '_'            ));            return $volt;        },        '.phtml' => 'Phalcon\Mvc\View\Engine\Php'       // '.volt' => 'Phalcon\Mvc\View\Engine\Php'    ));    return $view;});

Module. php under the Module is still generated during Project production, no changes!

In views/index. volt

Load partials

{{ partial("partials/header") }}{{ partial("partials/main") }}{{ partial("partials/footer") }}

Load js

{{ javascript_include("/js/1.11.3.jquery.min.js?1.1.15") }}

Reply content:

The multi-module project generated by the volt engine does not work. js and css load does not respond, and partials does not work well. the view cannot be output. does it seem that the volt engine is not successfully registered or is it another reason?

Ps: but comes with an engine. Files suffixed with. phtml can be imported into js, css, and partials files according to the manual. On the basis of the above, after changing the suffix to the. volt format, what else do I need to change?

Directory structure

The following is part of the code in config/services. php, which is automatically generated when a project is generated.

$di->setShared('view', function () use ($config) {    $view = new View();    $view->setViewsDir($config->application->viewsDir);    $view->registerEngines(array(        '.volt' => function ($view, $di) use ($config) {            $volt = new VoltEngine($view, $di);            $volt->setOptions(array(                'compiledPath' => $config->application->cacheDir,                'compiledSeparator' => '_'            ));            return $volt;        },        '.phtml' => 'Phalcon\Mvc\View\Engine\Php'       // '.volt' => 'Phalcon\Mvc\View\Engine\Php'    ));    return $view;});

Module. php under the Module is still generated during Project production, no changes!

In views/index. volt

Load partials

{{ partial("partials/header") }}{{ partial("partials/main") }}{{ partial("partials/footer") }}

Load js

{{ javascript_include("/js/1.11.3.jquery.min.js?1.1.15") }}

Paste the code section of your volt template registered in DI
Paste your JavaScript and CSS code section
Paste the code section where you use partial
Paste code! Paste code! Paste code! Repeat three! Code-related issues are raised without code pasting.

$di->set('view', function () use ($config) {    $view = new View();    $view->setViewsDir(APP_PATH . $config->application->layouts_dir);    $view->registerEngines(        array(            '.volt'  => function ($view, $di) use ($config) {                $volt = new VoltExtension($view, $di);                $volt->setOptions(                    array(                        'compiledPath'      => APP_PATH . $config->application->cache_dir,                        'compileAlways'     => $config->application->debug,                        'compiledSeparator' => '_',                        'layoutDir'         => $config->application->layouts_dir,                    ));                if (!empty($config->volt->extensions)) {                    foreach ($config->volt->extensions as $extension_class_name) {                        $di->get('volt.extension')->register($volt, new $extension_class_name($di));                    }                }                return $volt;            },            '.phtml' => 'Phalcon\Mvc\View\Engine\Php'            ......        ));    return $view;}, true);

Directory structure

Below are some of the code in config/services. php, which is automatically generated when a project is generated.

$di->setShared('view', function () use ($config) {    $view = new View();    $view->setViewsDir($config->application->viewsDir);    $view->registerEngines(array(        '.volt' => function ($view, $di) use ($config) {            $volt = new VoltEngine($view, $di);            $volt->setOptions(array(                'compiledPath' => $config->application->cacheDir,                'compiledSeparator' => '_'            ));            return $volt;        },        '.phtml' => 'Phalcon\Mvc\View\Engine\Php'       // '.volt' => 'Phalcon\Mvc\View\Engine\Php'    ));    return $view;});

Module. php under the Module is still generated during Project production, no changes!

In views/index. volt

Load partials

{{ partial("partials/header") }}{{ partial("partials/main") }}{{ partial("partials/footer") }}

Load js

{{ javascript_include("/js/1.11.3.jquery.min.js?1.1.15") }}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.