Fórumok

Removing page templates - not through control panel

Lior Hadaya, módosítva 11 év-val korábban

Removing page templates - not through control panel

Regular Member Bejegyzések: 138 Csatlakozás dátuma: 2012.01.24. Legújabb bejegyzések
Hello,

I'm using Liferay EE 6.1.20, and I need to remove the 3 page templates that come with Liferay out of the box (blog, wiki, content display page).

I know it can be done through the Page template portlet in the control panel, but my question is - is there a way to do it during or before deployment automatically, without having to go through the control panel?

Thanks,

Lior
thumbnail
Hitoshi Ozawa, módosítva 11 év-val korábban

RE: Removing page templates - not through control panel

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
I need to remove the 3 page templates that come with Liferay out of the box (blog, wiki, content display page).


Confused by your question. Are you trying to remove blog, wiki, and web content portlet? Instead of removing them, you can disable them.
Lior Hadaya, módosítva 11 év-val korábban

RE: Removing page templates - not through control panel

Regular Member Bejegyzések: 138 Csatlakozás dátuma: 2012.01.24. Legújabb bejegyzések
I'm not talking about the portlets, I'm talking about the page template.
When you create a new page Liferay allows you to select a page template, there are 3 options.

In the control panel under Portal there's a Page Templates option which allows you to delete these templates.

I want to somehow remove them automatically..
thumbnail
Anil Sunkari, módosítva 11 év-val korábban

RE: Removing page templates - not through control panel

Expert Bejegyzések: 427 Csatlakozás dátuma: 2009.08.12. Legújabb bejegyzések
Hi Lior,

I think you can achieve it through overriding liferay-layout-templates.xml from your plugins.Hope it helps you!!

Regards,
Anil Sunkari
Lior Hadaya, módosítva 11 év-val korábban

RE: Removing page templates - not through control panel

Regular Member Bejegyzések: 138 Csatlakozás dátuma: 2012.01.24. Legújabb bejegyzések
Hi,
liferay-layout-templates.xml seems to be dealing with layout templates (2_columns_i, 2_columns_iI and so on), while I'm talking about page templates (blog, wiki, content display page)
thumbnail
Anil Sunkari, módosítva 11 év-val korábban

RE: Removing page templates - not through control panel

Expert Bejegyzések: 427 Csatlakozás dátuma: 2009.08.12. Legújabb bejegyzések
liferay-layout-templates.xml seems to be dealing with layout templates (2_columns_i, 2_columns_iI and so on), while I'm talking about page templates (blog, wiki, content display page)



If i'm correct blog, wiki, content display you dont want to display these portlets.If so you can override it from portlet.xml where.Correct me still i'm wrong.

Regards,
Anil Sunkari
thumbnail
Jan Geißler, módosítva 11 év-val korábban

RE: Removing page templates - not through control panel (Válasz)

Liferay Master Bejegyzések: 735 Csatlakozás dátuma: 2011.07.05. Legújabb bejegyzések
Write a hook, read all LayoutPrototypes, iterate over them, remove the Prototypes you don't need from the database. You have to do this iterating stuff, as the Names of the LayoutPrototype are internationalized. So you have to do a String Compare over the Name with your local.

Method which should help:

LayoutPrototypeLocalServiceUtil.getLayoutPrototypes(start, end)
layoutPrototype.getName(Locale)
LayoutPrototypeLocalServiceUtil.deleteLayoutPrototype(layoutPrototype)


Hope this helps.
Lior Hadaya, módosítva 11 év-val korábban

RE: Removing page templates - not through control panel

Regular Member Bejegyzések: 138 Csatlakozás dátuma: 2012.01.24. Legújabb bejegyzések
Thank you Jan!
This is exactly what I was looking for.
For some reason when I call LayoutPrototypeLocalServiceUtil.deleteLayoutPrototype I get this exception, any idea why?
 java.lang.NoSuchMethodError: com.liferay.portal.service.LayoutPrototypeLocalServiceUtil.deleteLayoutPrototype


This is the code:

	try {
		List<layoutprototype> lps = LayoutPrototypeLocalServiceUtil.getLayoutPrototypes(QueryUtil.ALL_POS , QueryUtil.ALL_POS);
		LayoutPrototype blog = null;
		for (LayoutPrototype lp : lps) {
			if (lp.getName(Locale.getDefault()).equals("Blog")) {
				blog = lp;
				System.out.println("set blog");
			}
		}
		if (blog!=null) {
			try {
				LayoutPrototypeLocalServiceUtil.deleteLayoutPrototype(blog.getLayoutPrototypeId());
				System.out.println("deleted blog");
			} catch (PortalException e) {
				e.printStackTrace();
			}
		}
	} catch (SystemException e) {
		e.printStackTrace();
	}
</layoutprototype>

I tried passing the actual LayoutPrototype object or it's ID but neither worked.

Thanks again
thumbnail
Jan Geißler, módosítva 11 év-val korábban

RE: Removing page templates - not through control panel

Liferay Master Bejegyzések: 735 Csatlakozás dátuma: 2011.07.05. Legújabb bejegyzések
Hmmmm.... Strange. That made me curious, so I started diggin through the code, and I think I know why this error occurs.
There is a bug in ServiceBuilder (at least in 6.1 GA1) where Methods with return type void, called from an external Portlet will throw exactly this kind of error. So I looked in LayoutPrototypeServiceImpl class and look what I've found:

@Override
	public void deleteLayoutPrototype(LayoutPrototype layoutPrototype)
		throws PortalException, SystemException {

		// Group

		Group group = layoutPrototype.getGroup();

		groupLocalService.deleteGroup(group);

		// Resources

		resourceLocalService.deleteResource(
			layoutPrototype.getCompanyId(), LayoutPrototype.class.getName(),
			ResourceConstants.SCOPE_INDIVIDUAL,
			layoutPrototype.getLayoutPrototypeId());

		// Layout Prototype

		layoutPrototypePersistence.remove(layoutPrototype);

		// Permission cache

		PermissionCacheUtil.clearCache();
	}

	@Override
	public void deleteLayoutPrototype(long layoutPrototypeId)
		throws PortalException, SystemException {

		LayoutPrototype layoutPrototype =
			layoutPrototypePersistence.findByPrimaryKey(layoutPrototypeId);

		deleteLayoutPrototype(layoutPrototype);
	}


So long story short: Right now I think there would be only one way to fix this error. Retrieve Liferay-Portal Source code, change the return type of these methods, and recompile the portal. emoticon
Sorry that I can't help you any further....

Edit:
See here: http://issues.liferay.com/browse/LPS-2855
and here: http://issues.liferay.com/browse/LPS-11925

EDIT2:
After rereading the Issues in Jira I think this may not be related. You should open a Bug Report for this issue in Jira.

So long
Lior Hadaya, módosítva 11 év-val korábban

RE: Removing page templates - not through control panel

Regular Member Bejegyzések: 138 Csatlakozás dátuma: 2012.01.24. Legújabb bejegyzések
Thank you Jan for all your help, I appreciate it!