構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Morad Ahmad
Access Website Custom Attribute in a Theme
2012/08/26 8:58
答え

Morad Ahmad

ランク: Junior Member

投稿: 36

参加年月日: 2010/06/16

最近の投稿

Hi,

I see the topic was investigated bevore. But I have the specific problem to get custom attrs values for a website.

I defined the custom attr "Type" for Websites to handle different sites according to their type.

Know I want to disply in the theme "portal_normal.vm" a menu with all sites of a specific type, say "city"

1. First Try:

...
#set ($groupLocalService = $serviceLocator.findService("com.liferay.portal.service.GroupLocalService"))
#set ($groupsCount = $groupLocalService.getGroupsCount())
#set ($allGroups = $groupLocalService.getGroups(0, $groupsCount))

#set ($gtyp = $group.getExpandoBridge().getAttribute("Type") )

...

2. Try:

...
#set ($gtyp = $group.getLayout().getExpandoBridge().getAttribute("Typ") )
...

3. Try

#set ($gtyp = $expandoValueLocalService.getData($group.getGroupId(),"com.liferay.portal.model.Website", "CUSTOM_FIELDS", "Typ", ... );


I also try to get webseites with webseiteLocalService

##set ($websiteService = $serviceLocator.findService("com.liferay.portal.service.WebsiteLocalService"))
##set ($sitesCount = $websiteService.getWebsitesCount())
##set ($allSites = $websiteService.getWebsites() )
##<h1> Anzahl = $sitesCount </h1>

But I didn't succed in all!:-). I am not a velocity programmer.

How to manage that?

Thanks,
Morad.
Thomas Berg
RE: Access Website Custom Attribute in a Theme
2012/09/06 1:33
答え

Thomas Berg

ランク: Regular Member

投稿: 121

参加年月日: 2009/09/07

最近の投稿

Hello Morad,

I had the same requirement and got it working. I added a website attribute through the control-panel and I am able to access it in the theme like this:

1#set ($site_shortname = $themeDisplay.getScopeGroup().getExpandoBridge().getAttribute("shortName"))


HTH

Thomas
Morad Ahmad
RE: Access Website Custom Attribute in a Theme
2012/09/11 5:49
答え

Morad Ahmad

ランク: Junior Member

投稿: 36

参加年月日: 2010/06/16

最近の投稿

Thanks Thomas,

but what I need is not the current group. I must read the attribute for each website in a foreach loop:


#foreach ($group IN $allGroups)
#if ($group.isSite())
#set ($type =....getAttribute("Type")) ## for group in iteration????
#if(!$group.isControlPanel())
#if($group.getGroupId() % 4 == 0)
#set ($myPlaceURL = $portletURLFactory.create($request, "49", $getterUtil.getLong($plid), "ACTION_PHASE"))
${myPlaceURL.setWindowState("normal")}
${myPlaceURL.setPortletMode("view")}
${myPlaceURL.setParameter("struts_action", "/my_sites/view")}
${myPlaceURL.setParameter("groupId", ${group.getGroupId().toString()})}
<li><a href="${myPlaceURL.toString()}">$group.getName()</a></li>
#end
#end
#end
#end


I am ver surprised why the WebsiteLocalService returns null/empty list when I try to get Websites in the portal? Is it a bug or I do it wrong??

Thanks,
Morad.