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 » Developer » EZ5 Fetch ULR
expandshrink

EZ5 Fetch ULR

EZ5 Fetch ULR

Friday 11 July 2014 4:34:22 pm - 2 replies

Sub everyone,
did anyone know how to fetch URLs out of the location ids ?
Thanks alot !

Modified on Friday 25 July 2014 4:54:35 pm by David Keller

Friday 11 July 2014 11:22:55 pm

Hey David!

I don't know if this is the recommended way, but I do it like this:

$repository = $this->getContainer()->get( 'ezpublish.api.repository');
$urlAliasService = $repository->getURLAliasService();
 
// Get path  from LocationId
$locationId = 123;
$urlAlias = $urlAliasService->reverseLookup( $locationId, $languageCode = null );
$path = $urlAlias->path;
 
// Get LocationId from Path
$urlAlias = $urlAliasService->lookup( $path, $languageCode = null );
$locationId = $urlAlias->destination;

I added the languageCode variable only to show that you can also supply a language code - if you omit it, the default language will be used.

Cheers
- Jérôme 

Friday 25 July 2014 4:58:59 pm

Hey Jéróme,
thanks alot, it works perfectly.
- David

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from