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 » Location URL alias from a controller
expandshrink

Location URL alias from a controller

Location URL alias from a controller

Thursday 21 May 2015 11:30:24 am - 2 replies

Hi,

How could I get the URL alias associated to a location from a controller (equivalent to {{ path( location ) }} in Twig) ?

Thanks,

Hakim

Modified on Thursday 21 May 2015 11:31:02 am by Hakim Bouras

Thursday 21 May 2015 12:07:45 pm

you can use router service for that. try

 <?php
$this->get( 'router' )->generate( $location ); 

Thursday 21 May 2015 2:59:30 pm

Thanks Carlos, it was exactly what I needed.

And for whom it may help, you can get the absolute URL this way :

$this->get( 'router' )->generate( $location, [], UrlGeneratorInterface::ABSOLUTE_URL );

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from