Forums de discussion

How to disable functionality of creating pages with duplicate name

thumbnail
Vatsal Upadhyaya, modifié il y a 8 années.

How to disable functionality of creating pages with duplicate name

New Member Publications: 10 Date d'inscription: 20/10/15 Publications récentes
How can I disable creation of pages with duplicate names , i.e. If a page with name "Test" exists in that case user cannot add another page with same name. Site should give some type of warning.

TIA.
thumbnail
Andrew Jardine, modifié il y a 7 années.

RE: How to disable functionality of creating pages with duplicate name

Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
Hi Vatsal,

The page names don't need to be unique in Liferay, only the friendly URLs do. You'll find that if you try to create two pages, even if they have different names, with the same friendly URL then you will get an error (provided this test is done within the context of a single site).

There are a few ways you can add this prevention mechanism if you want.

1. You could create a JSP hook for the Site Management page and onblur for the field make an ajax call to validate that the name is unique.

2. You could use a StrutsActionHook to override the EditLayoutAction (I think that is the one anyway, I haven't checked) and do the check server side.

3. You could use a model listener with an onBeforeCreate to do the check.

-- of the three, I would say that #2 feels like the cleanest to me to be honest. Either way I don't think there is a setting or property that you can toggle to force this.
thumbnail
Vatsal Upadhyaya, modifié il y a 7 années.

RE: How to disable functionality of creating pages with duplicate name

New Member Publications: 10 Date d'inscription: 20/10/15 Publications récentes
Thanks Andrew.