Message-ID: <840368044.2782.1485850782382.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_2781_549846870.1485850782382" ------=_Part_2781_549846870.1485850782382 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Knowledge of the root location is important since it can be a starting p= oint for API queries, or even links to home page, but as eZ Platform can be= used for multisite development, the root location can vary.
By default, the root location ID is 2
, but as it can be eas=
ily be changed by configuration, the best practice is to retrieve i=
t dynamically.
Root location ID can be retrieved easily from ConfigResolver. The =
parameter name is content.tree_root.location_id
.
<?php namespace Acme\TestBundle\Controller; use eZ\Bundle\EzPublishCoreBundle\Controller; class DefaultController extends Controller { public function fooAction() { // ... $rootLocationId =3D $this->getConfigResolver()->getParameter(= 'content.tree_root.location_id' ); // ... } }=20
Root location is exposed in the global Twig helper.= p>
<a href=3D"{{ path( ezpublish.rootLocation ) }}" title=3D"L= ink to homepage">Home page</a>=20
<?php namespace Acme\TestBundle\Controller; use eZ\Bundle\EzPublishCoreBundle\Controller; class DefaultController extends Controller { public function fooAction() { // ... $rootLocation =3D $this->getRootLocation(); // ... } }=20