Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Problems overwriting master page with feature

  Asked By: Arnold    Date: Jul 01    Category: Sharepoint    Views: 3529

I have my custom branding files wrapped up in a feature (copies master page and
page layouts to master page gallery, feature receiver sets site's master page to
custom master, etc). When I create a site from scratch and install/activate this
feature, there are no problems. Branding looks as it should.

If I update the branding files, the existing branding files will not be
overwritten. (Btw, if I have new files, those new files will show up in the
gallery so I know the feature is working). Any ideas why?

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Latrice Henson     Answered On: Jul 01

You can't update  the Branding files  in the master  page gallery  while they are in
use. However, if you copied the files to the masterpage gallery using a
<Module> feature  and set it to Type=GhostableInLibrary you will be able to
update the original copies in the Feature directory, which will be picked up by
the ghosted copy in the masterpage gallery as long as you haven't edited it
using SPD.

 
Answer #2    Answered By: Nidhi Tiwary     Answered On: Jul 01

So if I edit those files  in Designer I've essentially put some lock on
them? (Why is Designer such a pain? Is it better just to use VS?)

Just to clarify, yes my feature  has module with the
GhostableInLibrary. Also, I've even tried to set the master  page for
all sites  to the default and tried to delete the files by hand but I
get an error saying they are still in use so they can't be deleted.

 
Answer #3    Answered By: Beatrice Serrano     Answered On: Jul 01

There are actually a couple different issues involved here so let me try to
explain.

Files that are uploaded or created inside SharePoint only reside in the Content
Database for the SharePoint site. But files  that are added to a site  through a
Feature (like your master  page) reside on the file system and are pointed to by
a record in the content database. These files are called uncustomized (or
ghosted). When one of these files is directly edited in SharePoint Designer the
edited version is stored directly in the content database and no longer points
to the copy in the file system. These are called customized (or unghosted)
files.

When you first activate your feature  module it ghosts the masterpage to the
MasterPage gallery  of the site and then uses a feature Receiver to change the
web site MasterUrl property to point at the new masterpage. At this point the
file is uncustomized. If you update  the original copy in the Feature directory
the one in the Gallery will appear to update as well, because it still points at
the original file. If on the other hand you try to update and Re-activate the
Feature it will fail because you are trying to update a file in the MasterPage
gallery that it knows is currently in use as a MasterPage. This is the same
error you get when you try to delete the file from the gallery (You also have to
do an IISreset to clear the cache of course). This lock is because the file is
being used, and has nothing to do with SharePoint Designer. However, as I said
you can still update the source of the uncustomized file in the 12 hive and the
changes will take effect. If you want to physically change the master page  in
the gallery you need to point any site using it to a different master page
first.

SharePoint Designer enters into all this because if you edit the master page
from the gallery in SharePoint Designer you will customize the file with a local
copy. Then you won't be able to change it by updating the source file in the 12
hive.

 
Answer #4    Answered By: Maya Lewis     Answered On: Jul 01

I forgot to mention. Compare your feature  to the one I have posted on my BLOG
for use in a non-publishing site.

 
Didn't find what you were looking for? Find more on Problems overwriting master page with feature Or get search suggestion and latest updates.




Tagged: