Message-ID: <372473628.2774.1485850759569.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_2773_1248033704.1485850759569" ------=_Part_2773_1248033704.1485850759569 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
It is possible to dynamically inject variables in content view templates=
by listening to the ezpublish.pre_content_view
event.
The event listener method receives an eZ\Publish\Core\MVC\Sym=
fony\Event\PreContentViewEvent
object
The following example will inject foo
and osTypes variables in all content view templates.
<?php namespace Acme\DemoBundle\EventListener; use eZ\Publish\Core\MVC\Symfony\Event\PreContentViewEvent; class PreContentViewListener { public function onPreContentView( PreContentViewEvent $event ) { // Get content view object and inject whatever no need. // You may add some custom business logic here. $contentView =3D $event->getContentView(); $contentView->addParameters( array( 'foo' =3D> 'bar', 'osTypes' =3D> array( 'osx', 'linux', 'win' ) ) ); } }=20
parameters: ezdemo.pre_content_view_listener.class: Acme\DemoBundle\EventListener\P= reContentViewListener services: ezdemo.pre_content_view_listener: class: %ezdemo.pre_content_view_listener.class% tags: - {name: kernel.event_listener, event: ezpublish.pre_content_vi= ew, method: onPreContentView}=20
Default view templates= span>