Download the PHP package bez/zfview-bundle without Composer
On this page you can find all versions of the php package bez/zfview-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bez/zfview-bundle
More information about bez/zfview-bundle
Files in bez/zfview-bundle
Package zfview-bundle
Short Description Multi-step layouts and view helpers for Symfony2 via Zend\View component
License MIT
Homepage https://github.com/bezhermoso/ZfViewBundle
Informations about the package zfview-bundle
ZfViewBundle
Brings the Zend\View templating paradigm of composite views and view helpers within your Symfony2 project.
2014-01-22 update:
$container->get('templating')->renderResponse('path/to/template.phtml', array $vars)
should now be working as expected.- Layout can now be set from within templates.
Installation
You can install this bundle via Composer:
php composer.phar require bez/zfview-bundle:v0.1.0
Register the bundle in app/AppKernel.php
:
Add "zf_view"
to the templating engines in your config.yml
:
Defining Templates and Layouts
Define the template and the layout to use using the @Bez\ZfViewBundle\Configuration\Rendering
annotation.
In src/FooBundle/Resources/views/Some/some.phtml
:
Child views -- in this case, src/FooBundle/Resources/views/Some/some.phtml
-- are evaluated before the parent layouts.
The output is captured to the $this->content
variable and thus can be injected into the layout as follows:
In src/FooBundle/Resources/layout.phtml
The fact that child views are evaluated first is very significant. This allows child views to modify elements (i.e., stylesheets, scripts, menus, etc.) in the parent layout by means of view helpers.
Overriding rendering options
Layouts can also be defined within the @Rendering
annotation in a method and will take precedence:
You can also set layout
to "none"
to disable a layout if one is defined at the class level. This will simply render the template without wrapping it any layout:
Defining the layout within templates
This is certainly useful when you wish to substitute templates used by third-party bundles through your application configuration. Declaring layouts in this manner will override any rendering configuration on the controller that are set via annotations.
In your template file:
Template names
As you can see in the above examples, you can omit the format
part in naming your phtml
templates. That is, FooBundle:Controller:template.phtml
is equivalent to FooBundle:Controller:template.html.phtml
.
The bundle will look for bundle:controller:name.format.phtml
or bundle:controller:name.phtml
and will use whichever exists.
Explicit view composition
Returning a pre-configured ViewModel is also possible:
View Helpers
Learn more about view helpers here: View helpers documentation
Contributing
Contributions are very welcome!
No unit tests yet.
All versions of zfview-bundle with dependencies
symfony/framework-bundle Version >=2.3
zendframework/zend-view Version 2.2.*
zendframework/zend-servicemanager Version 2.2.*
zendframework/zend-filter Version 2.2.*
zendframework/zend-escaper Version 2.2.*