10

Generate link in PHP using eZ Platform API

 3 years ago
source link: https://www.symfony.fi/ez-platform-tip/generate-link-in-php-api-using-ez-platform
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Generate link in PHP using eZ Platform API

In eZ Platform there are plenty of links to go around as you create locations and tree structures. In templates it is well documented how to generate links to locations, but in PHP this is not well documented.

Here is how to do it:


// Load the URL Alias Generator service from the container
$urlAliasGenerator = $this->get('ezpublish.urlalias_generator');

// Get path
$urlAliasGenerator->getPathPrefixByRootLocationId($hit->valueObject->id);

That's easy, nothing to it. You just need to know how to do it. There might be some issues with siteaccess paths with this method, though.


Written by Jani Tarvainen on Monday December 5, 2016
Permalink -

« Facebook sharing metadata for eZ Platform with Open Graph Bundle - Using a eZ Platform / eZ Publish 5.4 for local development without images »


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK