Expand my Community achievements bar.

SOLVED

How to create pages dynamically in sites

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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

View solution in original post

9 Replies

Avatar

Correct answer by
Employee Advisor

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

Avatar

Level 3

Hi,

I am creating pages dynamically using page manager but I want to use editable template for these pages. I don't know how to use editable template while creating pages. The editable template has a few initial components which should show up when page is created and I want all those root nodes to get added while creating pages.

Could you please let me know how to achieve it?

 

Thanks

Harpreet

Avatar

Community Advisor

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

Avatar

Community Advisor

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 ?

Avatar

Level 2

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.

Avatar

Employee Advisor

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

Avatar

Level 2

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.

Avatar

Employee Advisor

Hi,

can't you reference them simply by a link? Store the page at a central location and link it from all other pages?

Jörg

Avatar

Community Advisor

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.