Ibexa DXP Discussions

Community discussion forum for developers working with Ibexa DXP

Urlalias not working

Hi,

Why doesn’t this work when I have custom urlalias defined:

<a href="{{ path( 'ez_urlalias', {'locationId': 123}) }}">Some Link</a>

It always displays the system url.

I solved it through twig extensions (example bellow), but I’m not happy with it. Is there a more elegant solution?

BR

Example:

<a href="{{ ezurl(123) }}">SomeLink</a>

public function ezurl($locationId)
{
    $location = $this->locationService->loadLocation($locationId);

    if($this->urlAliasService->listLocationAliases($location, true)) {
        return $this->urlAliasService->listLocationAliases($location, true)[0]->path;
    }

    return $this->urlAliasService->listLocationAliases($location, false)[0]->path;
}

Did you try to regenerate urlalias ?

  • Backup your database
  • php -dmemory_limit=-1 bin/console ezplatform:urls:regenerate-aliases --location-id=123 --env=prod
  • Clear cache