フォーラム

ホーム » Liferay Portal » English » 2. Using Liferay » General

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Joshua Asbury
Friendly URL In Velocity Template
2009/04/15 11:54
答え

Joshua Asbury

LIFERAY STAFF

ランク: Expert

投稿: 497

参加年月日: 2006/09/08

最近の投稿

I have created a template which uses the link to page feature in the structure -- linking an image to a page.
1#if ($image-link.getData() != "")
2                    <a href="$image-link.getUrl()"
3                #end


The getUrl() works fine, but I am wondering if there is a way to get the Friendly URL in a template. Any ideas?
Amos Fong
RE: Friendly URL In Velocity Template
2009/04/16 17:27
答え

Amos Fong

LIFERAY STAFF

ランク: Liferay Legend

投稿: 1898

参加年月日: 2008/10/07

最近の投稿

Hey Josh,

I can't think of an easy way to do it...

 1#set ($layoutLocalService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalServiceUtil"))
 2
 3#set ($layoutId = $getterUtil.getLong($image-link.getData()))
 4
 5#set ($themeDisplay = $request.get('theme-display'))
 6#set ($currentPlid = $getterUtil.getLong($themeDisplay.get('plid')))
 7#set ($currentLayout = $layoutLocalService.getLayout($currentPlid))
 8
 9#set ($layout = $layoutLocalService.getLayout($getterUtil.getLong($groupId), $currentLayout.isPrivateLayout(), $layoutId))
10
11@friendly_url_current@/@group_friendly_url@$layout.getFriendlyURL()
Antonio Marcos Bernal
RE: Friendly URL In Velocity Template
2009/06/23 2:06
答え

Antonio Marcos Bernal

ランク: New Member

投稿: 6

参加年月日: 2009/05/19

最近の投稿

hi !!

i have a template with a page link and i used <a href="$ilink.getUrl()"/> to go to this page , but now i need to show the friendly_url instead of web/guest/10209/8 for example..
With your code i can show the friendly url of the actual page but no the link page url that show the mozilla when i used the href
Can anybody help me?
Thank you very much
Antonio Marcos Bernal
RE: Friendly URL In Velocity Template
2009/06/23 2:53
答え

Antonio Marcos Bernal

ランク: New Member

投稿: 6

参加年月日: 2009/05/19

最近の投稿

Excuse me but i see my problem is only that $currentLayout = $layoutLocalService.getLayout($currentPlid)) don´t return anything,,,anybody test this code??
Amos Fong
RE: Friendly URL In Velocity Template
2009/06/23 11:55
答え

Amos Fong

LIFERAY STAFF

ランク: Liferay Legend

投稿: 1898

参加年月日: 2008/10/07

最近の投稿

Did you enable the servicelocator in your templates?

in portal.properties:

journal.template.velocity.restricted.variables=

http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Access+to+Liferay+services+in+Velocity
Robert Kornmesser
RE: Friendly URL In Velocity Template
2012/03/20 3:25
答え

Robert Kornmesser

ランク: Junior Member

投稿: 39

参加年月日: 2011/11/03

最近の投稿

Its NOT
1#set ($layoutLocalService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalServiceUtil"))

BUT
1#set ($layoutLocalService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))

Finding services works by looking up the bean name, not the util. Otherwise you get a "NoSuchBeanDefinitionException: No bean named 'com.liferay.portal.service.LayoutLocalServiceUtil' is defined"
Dave Weitzel
RE: Friendly URL In Velocity Template
2012/12/17 8:09
答え

Dave Weitzel

ランク: Regular Member

投稿: 203

参加年月日: 2009/11/18

最近の投稿

I have found this thread and though it solved my problem as well but it doesn't.

I have a custom navigation template that is part of the theme (user has added own links etc) .
I want to detect if the link is actually to the current "site" so I can give it a different class.

I see you are using :

@friendly_url_current@/@group_friendly_url@

as a way of getting the current site's url and when I put this in the journal temp[lpate as straight text it returns what I want:
/web/mysite

BUT if I create a velocity variable
#set ( $fURL = '@friendly_url_current@/@group_friendly_url@')
it will still print out correctly but when I do something like link.getData().startsWith($fURL) I never get a hit as fURL contains the string @friendly_url_current@/@group_friendly_url@ it has length 42 characters.

I have never seen these sort of variables: @friendly_url_current@/@group_friendly_url@ ?
Where do they come from?
How can I pre-process their results to use in velocity functions?

I am expanding the journal content directly in the theme templates so do not have themeDIsplay and other normal velocity functions to work with

Thanks
Corné Aussems
RE: Friendly URL In Velocity Template
2014/04/07 4:50
答え

Corné Aussems

ランク: Liferay Legend

投稿: 1311

参加年月日: 2006/10/03

最近の投稿

I was forwarded to this post, but its easier nowadays but for future references


1dynamic-element name="linkFoo" type="link_to_layout" index-type="" />
2$linkFoo.getFriendlyUrl()


updated: getFriendlyUrl >> getFriendlyURL
Corné Aussems
RE: Friendly URL In Velocity Template
2014/04/07 4:49
答え

Corné Aussems

ランク: Liferay Legend

投稿: 1311

参加年月日: 2006/10/03

最近の投稿

Mind the CAP, Mind the CAP, Mind the CAP,
Oops now i made the same assumption,

it should be

1$linkFoo.getFriendlyUrl()


NOT
$linkFoo.getFriendlyURL()