Message-ID: <1800547148.4286.1485862272594.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_4285_2142304284.1485862272593" ------=_Part_4285_2142304284.1485862272593 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 t=
emplates by listening to the ezpublish.pre_content_view<=
/strong>
event.
The event listener method receives an eZ\Publish\Core\M=
VC\Symfony\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