Most of the time we are using SharePoint Designer for master
page and page layout deployment, which is fine for first time going live
because for the first time we mostly used backup restore or other stuff.
But problem occurs when you want to update master page or
page layout in subsequent release. We can do that easily with SharePoint
designer but some unlucky fellow like us who do not have access to production
will have to find some workaround for that. And if master page and Page Layout being used then it will not allow to delete
and add it again.
Here are simple steps what we had done
- Add physical copy of master page/page layout in your project (or put it in 14 hive)
- Create a feature receiver which will read that file added in 14 hive, read as binary stream.
- Find master page in master page gallery (_catalog folder)
- If (not found) then add new master page/layout (will be used for first time deployment)
- If (found) then open/read master page/layout from library
- Check out
- Open as binary form and copy binary object from physical copy
- Commit transection, so new version will be added for master page/layout.
- Check in
- Publish
This way if master page is currently used in site or page
layout has been used any of the page you can easily update it from code.
It will not require access to production. You can add
feature receiver in WSP and activate it on deployment; and you are done.
We will provide code snippet for this soon :)
1 comment:
Please provide the code snippet for the above requirement.
Post a Comment