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") }}