Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Saurabh Gupta
How to set default template for web content?
February 4, 2013 9:54 PM
Answer

Saurabh Gupta

Rank: New Member

Posts: 23

Join Date: September 24, 2012

Recent Posts

Is there any way to set a default template for web content articles?

As such, when posting new web content in control panel, content administrators no need to select a template by default.

This can simple the process since less click and less page refreshes involved. Also it will help the adoption rate of those content administrator who are not so IT savvy. 'Structure' and 'Template' may be a little bit too technical for them. Simple is perfect!

I noticed there are parameters in the url can be used to set the default template:
1&_15_structureId=11149&_15_templateId=11151

and one more question, i created the Page Template for page and in this page template Web Content Display protlet is there and i add a new page with this Page template then i need to check from which Page Template this page is created. How can i do this programatically?
Oliver Bayer
RE: How to set default template for web content?
February 5, 2013 2:10 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 875

Join Date: February 18, 2009

Recent Posts

Hi Saurabh,

afaik you can achieve it only by coding it yourself. But the good news is: it shouldn't be that hard ;).

Create a jsp hook to override a jsp from "html \ portlet \ journal \" (my guess would be edit_article.jsp). Use JournalTemplateLocalServiceUtil methods to retrieve the template you want to select (maybe by using the template name and the template groupid or 0 for a global template). Now you can use the journal template object to retrieve the linked journal structure id. Set these two values (template id, structure id) programatically ONLY if the request doesn't contain them already (otherwise you would not be able to switch to another template anymore emoticon).

HTH Oli
Saurabh Gupta
RE: How to set default template for web content?
February 5, 2013 4:49 AM
Answer

Saurabh Gupta

Rank: New Member

Posts: 23

Join Date: September 24, 2012

Recent Posts

Oliver Bayer:
Hi Saurabh,

afaik you can achieve it only by coding it yourself. But the good news is: it shouldn't be that hard ;).

Create a jsp hook to override a jsp from "html \ portlet \ journal \" (my guess would be edit_article.jsp). Use JournalTemplateLocalServiceUtil methods to retrieve the template you want to select (maybe by using the template name and the template groupid or 0 for a global template). Now you can use the journal template object to retrieve the linked journal structure id. Set these two values (template id, structure id) programatically ONLY if the request doesn't contain them already (otherwise you would not be able to switch to another template anymore emoticon).

HTH Oli


Oliver Thank you for helping me

one more Question, i have created 3 page Template and when add the new Page then i am selecting the Page Template . in this Page Template, Web Content Display Portlet is there and according to Page Template i need to set the structure and template for Web Content Display. This will be very useful to user who need to create page with one Page Template and in this Page Template which have Web Content Display will get structure and template automatically according to Page Template. so user no need to set Structure and Template manually.
Oliver Bayer
RE: How to set default template for web content?
February 6, 2013 1:07 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 875

Join Date: February 18, 2009

Recent Posts

Hi Saurubh,

I've never used or modified page templates before but the sources seem to be located in "html \ portlet \ layout_prototypes". But I don't think you have to change sth. there. If you select your page template you will get a blank/ empty web content display portlet right? So if a user clicks on "add new web content" the changes of the mentioned hook should apply and the default template/ structure (selected by e.g. name and group) should be set automatically. If it's not what you're looking for or if you find another solution please let me know.

Greets Oli
Saurabh Gupta
RE: How to set default template for web content?
February 6, 2013 6:26 AM
Answer

Saurabh Gupta

Rank: New Member

Posts: 23

Join Date: September 24, 2012

Recent Posts

Thank you for reply
yes, you are correct i need this thing but the problem is that i need to change the structure and template according to Page Template.
Oliver Bayer
RE: How to set default template for web content?
February 7, 2013 1:31 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 875

Join Date: February 18, 2009

Recent Posts

Hi,

ah ok, now I understand your requirement.

Maybe you can retrieve the page template by using:
1String pageTemplateUuid = layout.getLayoutPrototypeUuid()

Oli
Saurabh Gupta
RE: How to set default template for web content?
February 11, 2013 10:51 PM
Answer

Saurabh Gupta

Rank: New Member

Posts: 23

Join Date: September 24, 2012

Recent Posts

@Oliver Thank you very much