Legacy Knowledge Base
Published Jul. 2, 2025

$reserved-article-url-title.data doesn't provide i18n friendly URL

Written By

Jorge García Jiménez

How To articles are not official guidelines or officially supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

While we make every effort to ensure this Knowledge Base is accurate, itmay not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with anyfeedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability for your situation and project.

Issue

  • If you have a content with different friendly URLs per language, when trying to retrieve those friendly URL via velocity template, $reserved-article-url-title.data doesn't provide internationalized URL.
  • Per example, you have a web content with below URLs for Spanish (ES) and English (EN):
    • friendly URL ES: http://localhost:8080/es/web/test-page/-/testcontentes
    • friendly URL EN: http://localhost:8080/en/web/test-page/-/testcontenten
  • If you create a Web Content Template with $reserved-article-url-title.data to retrieve URL, it doesn't show a different URL per locale: a URL for the default locale is shown.

Environment

  • Liferay DXP 7.2

Resolution

  • In order to show a different URL per locale in a web content template, you have to obtain the friendly-URL based on its FriendlyUrlEntryLocalization.
  • Below is an example that could be used for velocity templates:
    #set ($longGroupId = $getterUtil.getLong($groupId))
    #set ($journalArticleResourceService = $serviceLocator.findService("com.liferay.journal.service.JournalArticleResourceLocalService"))

    #set($articleResource = $journalArticleResourceService.fetchArticleResource($longGroupId,$reserved-article-id.data))
    #set ($articleResourcePK = $articleResource.getResourcePrimKey())

    #set ($classNameLocalService = $serviceLocator.findService("com.liferay.portal.kernel.service.ClassNameLocalService"))
    #set ($friendlyUrlEntryService = $serviceLocator.findService("com.liferay.friendly.url.service.FriendlyURLEntryLocalService"))
    #set ($classnameId = $classNameLocalService.getClassNameId("com.liferay.journal.model.JournalArticle"))


    #set($entries = $friendlyUrlEntryService.getFriendlyURLEntries($longGroupId,$getterUtil.getLong($classnameId),$getterUtil.getLong($articleResourcePK)))

    #set($url-title = "")
    #foreach( $entry in $entries )
        #set($entryLocalization = $friendlyUrlEntryService.getFriendlyURLEntryLocalization($entry.friendlyURLEntryId,$locale.toString()))
        #set($url-title = $entryLocalization.urlTitle)
    #end

    $url-title
Did this article resolve your issue ?

Legacy Knowledge Base