PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, May 18, 2022

[FIXED] How to use ZF2 navigation twig partial

 May 18, 2022     navigation, partial, twig, zend-framework2     No comments   

Issue

I have layout.twig file with this line:

{{ navigation('navigation').menu().setUlClass("nav navbar-nav").setPartial(['partials/navigation.twig', 'Application'])|raw }}

inside of the navigation.twig I have these lines:

{{ ulClass }}
<?php echo "test"; die();?>

Unfortunately I see this as result:

{{ ulClass }}
test

Which means that twig file was parsed by default PHP render. How should I fix it? Please note layout.twig works just fine. Thanks.


Solution

The answer is to override invokables in the helper_manager section:

    'helper_manager' => array(
        'configs' => array(
            'Zend\Navigation\View\HelperConfig'
        ),
        'invokables' => array(
            "partial" => 'Zend\View\Helper\Partial',
            "paginationControl" => 'Zend\View\Helper\PaginationControl',
        )
    )

After that partials are being parsed as twig files, not php.



Answered By - Ilya Kovalyov
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,206,295

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing