フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Ron J
Creating sites & setting layout templates programmatically
2013/01/16 15:46
答え

Ron J

ランク: Junior Member

投稿: 45

参加年月日: 2012/11/18

最近の投稿

I'm trying to create a new site programmatically in one of my portlets and I want to apply a layout template that I've created. I used one of the organization views as a reference to get the templates but I'm struggling to get the template assigned to my new sites. I'm new to liferay and still learning how it works but found

 1
 2List<LayoutSetPrototype> lsps = LayoutSetPrototypeServiceUtil.search(themeDisplay.getCompanyId(), Boolean.TRUE, null);
 3
 4Layout layout = LayoutLocalServiceUtil.addLayout(userid, ng.getGroupId(), false,
 5                            0, SITE_LAYOUT_NAME, SITE_LAYOUT_TITLE, SITE_LAYOUT_DESC,
 6                            LayoutConstants.TYPE_PORTLET, true, "/"+name, ctx);
 7
 8for (LayoutSetPrototype curLSP: lsps)
 9{
10    if (HtmlUtil.escape(curLSP.getName()).equalsIgnoreCase(SITE_TEMPLATE_NAME))
11    {
12         LayoutTypePortlet ltp = (LayoutTypePortlet) layout.getLayoutType();
13      ltp.setLayoutTemplateId(userid, curLSP.getUuid());
14
15          LayoutLocalServiceUtil.updateLayout(ng.getGroupId(), layout.isPrivateLayout(),
16                                    layout.getLayoutId(), layout.getTypeSettings());
17    }
18}


I don't get any errors but my new sites are blank.. What am I missing?

Thanks
Olaf Kock
RE: Creating sites & setting layout templates programmatically
2013/01/20 10:39
答え

Olaf Kock

LIFERAY STAFF

ランク: Liferay Legend

投稿: 2436

参加年月日: 2008/09/23

最近の投稿

You might want to look at the sourcecode for sevencogs-hook, a plugin that came with Liferay CE until version 6.1.1 (GA1) (so you'll have to download an old version)

Unfortunately this plugin does not compile currently (some API changes), but it's well worth looking at it: The complexity is extremely low and it does exactly what you want to achieve - basically it uses the API to set up users, pages, articles, layouts etc.