Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Saurabh Gupta
How to set default template for web content?
4 de Fevereiro de 2013 21:54
Resposta

Saurabh Gupta

Ranking: New Member

Mensagens: 23

Data de entrada: 24 de Setembro de 2012

Mensagens recentes

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?
5 de Fevereiro de 2013 02:10
Resposta

Oliver Bayer

Ranking: Liferay Master

Mensagens: 889

Data de entrada: 18 de Fevereiro de 2009

Mensagens recentes

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?
5 de Fevereiro de 2013 04:49
Resposta

Saurabh Gupta

Ranking: New Member

Mensagens: 23

Data de entrada: 24 de Setembro de 2012

Mensagens recentes

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?
6 de Fevereiro de 2013 01:07
Resposta

Oliver Bayer

Ranking: Liferay Master

Mensagens: 889

Data de entrada: 18 de Fevereiro de 2009

Mensagens recentes

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?
6 de Fevereiro de 2013 06:26
Resposta

Saurabh Gupta

Ranking: New Member

Mensagens: 23

Data de entrada: 24 de Setembro de 2012

Mensagens recentes

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?
7 de Fevereiro de 2013 01:31
Resposta

Oliver Bayer

Ranking: Liferay Master

Mensagens: 889

Data de entrada: 18 de Fevereiro de 2009

Mensagens recentes

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?
11 de Fevereiro de 2013 22:51
Resposta

Saurabh Gupta

Ranking: New Member

Mensagens: 23

Data de entrada: 24 de Setembro de 2012

Mensagens recentes

@Oliver Thank you very much