-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use JsonModel and TwigModel #13
Comments
With this configuration 'zend_twig' => [
'force_twig_strategy' => false,
], If I return the json model like this public function indexAction()
{
return new JsonModel([
'testing' => 'Hello World'
]);
} I get the result as expected. See below But instead of JsonModel, if I return a TwigModel, the twig files does not render public function indexAction()
{
return new TwigModel([
'testing' => 'Hello World'
]);
} |
@Alfredao could you provide your configuration for module here and order of the modules in your application config (this module should be in the end, because of a way how zf3 is loading dependencies). |
Hi @OxCom My module order is return [
'Zend\Mvc\I18n',
'Zend\Hydrator',
'Zend\Router',
'Zend\Validator',
'DoctrineModule',
'DoctrineORMModule',
'Ecommerce',
'ZendTwig',
]; This configuration is in Ecommerce module config 'zend_twig' => [
'force_twig_strategy' => false,
'force_standalone' => false,
'invoke_zend_helpers' => true,
'environment' => [
],
'loader_chain' => [
\ZendTwig\Loader\MapLoader::class,
\ZendTwig\Loader\StackLoader::class,
],
'extensions' => [
\Ecommerce\View\Twig\Extension\Slugify::class,
\Ecommerce\View\Twig\Extension\Money::class,
],
'helpers' => [
'configs' => [
\Zend\Navigation\View\HelperConfig::class,
],
],
], |
@Alfredao Please check what type of the template do you have for this run: composer install
cd ./public
php -S localhost:8000 check: curl -D- http://127.0.0.1:8000/application/json
curl -D- http://127.0.0.1:8000/application/twig
curl -D- http://127.0.0.1:8000/application/index |
@OxCom Thank you for your time, this works ok. But can we render the layout/layout configured in template_map with Twig as well? 'view_manager' => [
'template_map' => [
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml', // this one with Twig
],
], My plan is to give a template example for others developers create it's own layout, like Shopify does. |
@Alfredao change it to {{ docType() }}
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
{{ headTitle('Hello World')|raw }}
{{
headMeta()
.appendName('viewport', 'width=device-width, initial-scale=1.0')
.appendName('subject', 'Hello subject.')
.appendName('description', 'World description.')
.appendHttpEquiv('X-UA-Compatible', 'IE=edge')
|raw
}}
{{
headLink()
.headLink({
'rel' : 'shortcut icon',
'type' : 'image/vnd.microsoft.icon',
'href' : ServerUrl('/img/favicon.ico'),
})
.appendStylesheet(ServerUrl('/css/styles.min.css'))
|raw
}}
</head>
<body>
{% block content %}
{{ content|raw }}
{% endblock content %}
{% block content_scripts %}
{{ content_scripts|default('')|raw }}
{% endblock content_scripts %}
</body>
</html> |
@Alfredao please update to the latest version with a fix. |
Hi @OxCom, tested yesterday! Thank you so much |
Hi
I'm having the same problem as #9, when returning a JsonModel instance, I got this fatal error instead of the json response.
If I set
force_twig_strategy
tofalse
, the JsonModel returns the json correctly, but then TwigModel does not render the twig templatesThere's something I can do to solve this problem? Thank you all
The text was updated successfully, but these errors were encountered: