This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » eZ Publish 5 Platform » Switch from content to location or...
expandshrink

Switch from content to location or reverse

Switch from content to location or reverse

Friday 14 November 2014 5:10:28 pm - 2 replies

Hi again,

Is there any easy way to grab the location from a content object or the content from a location ?

In twig ? In php ?

anything like :

$content->getMainLocation();

or

content.mainLocation

Thank you

Friday 14 November 2014 5:24:40 pm

AFAIK no. not so direct. You can use LocationService though. $content will have a contentInfo->mainLocationId property. So you can just do

$location = $this->getRepository()->getLocationService()->loadLocation( $content->contentInfo->mainLocationId )

Monday 17 November 2014 9:49:35 am

You can of course retrieve all available locations from a Content, using LocationService::loadLocations( $content->contentInfo ).

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from