Question

I'm using Zend Framework 2 (v2.1.4) and I have a partials template that I want to use in several Modules. According to the documentation I can access partials in other Modules, but

That said, it’s likely a better practice to put re-usable partials in shared view script paths.

This sounds like a good idea, but I can't find any documentation on this "share view script path". Where do I find it, and when I've set it, how do I tell the partial() helper to use them?

Was it helpful?

Solution

In your module.config.php

'view_manager' => array(
        'template_path_stack' => array(
            'mymodule' => __DIR__ . '/../view',
        ),
        'template_map' => array(
            'snippets/mypartial' => __DIR__ . '/../view/snippets/mypartial.phtml',
        ),
    ),

And use like that

<?php echo $this->partial("snippets/mypartial"); ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top