Forest header image

Symfony Finland
Random things on PHP, Symfony and web development

Load Location / Content by URL Alias in eZ Platform

Loading content by a URL alias is done using the URL Alias Service. To get the location and content you will need to do that manually as well. See example below:

$urlAliasService = $this->container->get('ezpublish.api.service.url_alias');
$locationService = $this->container->get('ezpublish.api.service.location');

$urlAlias = $urlAliasService->lookup('/blog');
$location = $locationService->loadLocation($urlAlias->destination);
$content = $location->getContent();

Written by Jani Tarvainen on Monday February 18, 2019
Permalink -

« Convert RichText to HTML in PHP API -