Updating SharePoint sites through the onet.xml file
I've updated a site definition in the SharePoint onet.xml file so new sites are created without a particular web page on a page.
However I've read that the onet.xml file is only read when a site is first crea开发者_运维百科ted.
Is there some way for me to get the existing sites to refresh??
It's not really partical to loop through each site and make the change.. even through code.
I'd think looping through every site from code is very practical? Doing it manually might not be.
You might not even have to code for it if you install the stsadm extensions. You can delete items using this command for instance and it has commands to enumerate sites with.
There is no other option to synchronize the changes made to onet.xml to be reflected in the existing site that are created based on the onet.xml.
- Loop through each of the site & create the Page is the option you are left with.
- Another alternate you could do is that you can create a Feature that will Provision web page file and activate it in each of the web.
- Finally one option I could think of is to place the page in _Layouts (If you are really against both the above options)
Do not modify onet.xml as this file can be overwritten when updating sharepoint!
And looping throught SPSite.AllWebs is not really impractical if you want to update SPWeb. Ofcourse, it would be impractical if you run this code each time item or whatever changes, but if you just need to fire this code once in a while, then this is no problem.
Oh right, but it may be a problem if you add new webs. Well, Kusek already provided you with an answer:
Another alternate you could do is that you can create a Feature that will Provision web page file and activate it in each of the web.
That's called feature stapling. Activate your feature when web has created and do your modifications for that web.
精彩评论