Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Kamesh Sampath
Apply Site Template from Prototype
December 6, 2012 1:08 AM
Answer

Kamesh Sampath

Rank: Regular Member

Posts: 159

Join Date: May 26, 2010

Recent Posts

Hi,

I am trying to create a Site using Liferay API, i was successfull doing that.

I now want to apply the Site Template to the created site, i was able to fetch LayoutPrototypeSet, I dont know how do I apply the same to the to the public pages of the new created site.

It will be great if any one can tell me the API classes which I can look into or any pointers the same will be of great help.

Thank you.

+Kamesh
Jan Geißler
RE: Apply Site Template from Prototype
December 6, 2012 2:13 AM
Answer

Jan Geißler

Community Moderator

Rank: Liferay Master

Posts: 720

Join Date: July 5, 2011

Recent Posts

See here. This should get you on track:

http://www.liferay.com/community/forums/-/message_boards/message/18392329
Kamesh Sampath
RE: Apply Site Template from Prototype
December 6, 2012 4:20 AM
Answer

Kamesh Sampath

Rank: Regular Member

Posts: 159

Join Date: May 26, 2010

Recent Posts

Jan Geißler:
See here. This should get you on track:

http://www.liferay.com/community/forums/-/message_boards/message/18392329


Thanks Jan, I did follow that but then i got bit confused with couple of main things there,

  1. How to get the Layout i.e. targetLayout from the Group(site)
  2. How layoutPrototype from my site template, do I need to use LayoutSetPropotoypeSetUtil?


Also, please let me know if had any tips and tricks when doing the same.

Thanks once again for the pointer.

+Kamesh
Jan Geißler
RE: Apply Site Template from Prototype
December 6, 2012 5:01 AM
Answer

Jan Geißler

Community Moderator

Rank: Liferay Master

Posts: 720

Join Date: July 5, 2011

Recent Posts

1.
1LayoutSet privateLayoutSet = group.getPrivateLayoutSet();


2.
1layoutSetPrototypes = LayoutSetPrototypeLocalServiceUtil.getLayoutSetPrototypes(0, LayoutSetLocalServiceUtil.getLayoutSetsCount());

or
1LayoutSetPrototypeLocalServiceUtil.getLayoutSetPrototypeByUuid(uuid)

As the LayoutSetPrototypesLocalServiceUtil Class does not have a Method to get the Prototypes by name (Think because they are localized) you would have to iterate over them and select the Prototype this way, or you hav a way to get UUID of it.
Kamesh Sampath
RE: Apply Site Template from Prototype
December 6, 2012 7:16 AM
Answer

Kamesh Sampath

Rank: Regular Member

Posts: 159

Join Date: May 26, 2010

Recent Posts

Jan,

I see your point is kind valid when I am kind of importing page by page, but in my case I need to apply the entire site template, see its like this, I have already created Page Template X and created a Site Template Y, the Site template Y's public page is mapped to my Page Template X. Now each site I create, i will pass the Site_Template name, then itreate through the company's site tempaltes, and pick the one matching my name. Now i have the LayoutSetPrototype, and ready to get it applied to my new Site.

Now (referring to SiteUtil from your pointer), i found that the Site tempalte application is done in the LAR fashion, first the LayoutSetPrototype is exported to LAR ( prbly cached for later use), then they are imported in to the new Site's Layout. That's the idea, this solves my issue emoticon

Please share any thoughts you might have.

Thank you.

+Kamesh
Jan Geißler
RE: Apply Site Template from Prototype
December 6, 2012 7:31 AM
Answer

Jan Geißler

Community Moderator

Rank: Liferay Master

Posts: 720

Join Date: July 5, 2011

Recent Posts

Actually the snippets ARE for whole LayoutSets (Site Template), not for a Layout (Page Template).
So it should work the way you want.
Julio Camarero
RE: Apply Site Template from Prototype
December 6, 2012 9:31 AM
Answer

Julio Camarero

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1659

Join Date: July 15, 2008

Recent Posts

Hi guys,

there is a cool example of this in Liferay tests. If you open LayoutExportImportTest.java in the latest development branch you can actually find an example for this.

cheers!
Kamesh Sampath
RE: Apply Site Template from Prototype
December 6, 2012 9:59 AM
Answer

Kamesh Sampath

Rank: Regular Member

Posts: 159

Join Date: May 26, 2010

Recent Posts

Thanks Julio for the pointer.

Ideally just to summarize how to do it,

1. Models required LayoutPrototype (Page Template) , LayoutSetPrototype (Site Templates), Group(Sites)
2. Refer to SiteUtil, and extract methods that might suit your needs, e.g. in my case I know the the Template on hand so iterated the available LayoutSetProtypes and compared their names to pick the one I need
3. Then on the Site util i just referred to two methods, importLayouts and getPrototypeParameters as those are the ones that I need to make it work.


+Kamesh