0

Migrating from Sharepoint 2010 to 2019 (On-Prem, Classic UI) and I need to implement a solution that automatically generates pages (3 for example) when a subsite is created.

An example would be subsites and subsite pages for departments in a business:

EX: If I create a new 'Finance' subsite under my root site and set the page layout via a terminal command, the solution should automatically generate 3 pages under that subsite in addition to the /default.aspx page: a 'People' page, 'Overview' page, and 'Contact' page. Each would use a custom layout set via a terminal command.

Am I looking for site definitions? Or a module (as described here)? I've poured through Microsoft's documentation but the specifications of our implementation (2019, On-Prem, Classic UI) have made it difficult to discern the next steps.

It would also be great to automatically generate lists when subsites are created too. Would a similar process be used to accomplish both? Or are they different solutions?

I have access to Sharepoint Designer and Visual Studio. I'm familiar with Sharepoint Designer, it's purpose, and how it interacts with our Sharepoint environment. Not as familiar with Visual Studio, so I dont know what I dont know about the tool.

Any help in the right direction would be much appreciated. Thank you!

0

You could create event receiver in Visual Studio to achieve this.

There are two such events - WebAdding (When the site is started to create) and WebProvisioned - When the site has been created. And you can use these event recievers to add some custom code to create pages and lists.

SPWebEventReceiver.WebAdding method: https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-server/ee586769(v=office.15)

SPWebEventReceiver.WebProvisioned method: https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-server/ee566718(v=office.15)

2
  • Thank you for the response and the links. This seems like the right direction. After doing some digging, could you confirm that I'm on the right path? I'm seeing that 'SPWeb' == a subsite, so I can use the SPWeb.add() method to define new sites as mentioned: stackoverflow.com/questions/11111234/… Is this accurate still? Because after looking at the docs, it seems like the add() method is on the SPWebCollection class (cant link due to length)
    – Callmelife
    Oct 14 '20 at 16:46
  • Yes, you are right. 'SPWeb' = a subsite Oct 15 '20 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.