How to create pages dynamically in sites

avantikas293534

20-06-2019

Hi All,

I am trying to create a page dynamically i.e on creating a page at a path, a copy of the same page should get created in the given path. The pages should also be dynamically linked to each other i.e a change in one should get reflected in another and vise versa.

Please let me know if it is possible.

Accepted Solutions (1)

Accepted Solutions (1)

Jörg_Hoh

Employee

20-06-2019

Of course this is possible. You can create pages via the PageManager API, but from then on you are on your own. You need to create the resources for the individual components on your own, also providing the correct content into the right properties etc. To make this work well you need to understand how your pages are structured and know your components.

Jörg

Answers (7)

Answers (7)

Jörg_Hoh

Employee

25-06-2019

Hi,

Well, there are ways to do that, but let me first ask the question why you want to do that. Having the same page available at multiple locations rarely makes sense per se, so there must be a business reason which I would like to understand first to give you a good recommendation.

Jörg

Ravi_Pampana

MVP

20-06-2019

Hi,

As mentioned by Jorg, you can use PageManager API to create page automatically in java using servlet/scheduler based on your requirement.

In order to keep the newly created page updated with existing page, we can create page as live copy of existing page. Below give you idea about creating page with live copy

Veena_Vikram

MVP

28-06-2019

I agree with Joerg. You can store the references as some properties in rest of your pages. As mentioned prior also , having multiple copies of same page doesn't seem to be an ideal solution at all.

avantikas293534

25-06-2019

Hi Joerg,

The example I stated above is the exact bussiness requirement.

There are certain contents that needs to be present(not as physical files but their reference is necessary) at multiple places .

So instead of creating those content at multiple locations , we want to make content once and give their reference at other paths.

avantikas293534

24-06-2019

Hi Joerg,

Thank you your reply,

Creating a physical page at the path is not necessary for my requirement,but the refrence should be present from multiple paths.

For Example,

I have created a Page X at path x/y/z/PageX

Now what I want is the refrence to this page should also be available from path a/b/c

So when I fire a query to extract all pages on x/y/z path then PageX should be available and

also when I fire a query to extract all pages on a/b/c path then also PageX should be available.

Is there any configuration or setting for adding data in my jcr so that reference for the page can be present at two paths based on certain conditions.

Veena_Vikram

MVP

20-06-2019

Avantika ,

    I am trying to understand your requirement here little more clearly. " i.e on creating a page at a path, a copy of the same page should get created in the given path" By this do you mean that when the author creates a page manually via siteadmin ; you want to create a copy of the same page via code ?

   What is the issue you are trying to address here ? I don't think keeping a copy of the same page under the same path is right way to do it ? There should be a better way to do . If you can share the problem you are trying to solve ?