留言板

How to disable functionality of creating pages with duplicate name

thumbnail
Vatsal Upadhyaya,修改在7 年前。

How to disable functionality of creating pages with duplicate name

New Member 帖子: 10 加入日期: 15-10-20 最近的帖子
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,修改在7 年前。

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

Liferay Legend 帖子: 2416 加入日期: 10-12-22 最近的帖子
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,修改在7 年前。

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

New Member 帖子: 10 加入日期: 15-10-20 最近的帖子
Thanks Andrew.