Customizing PlaceHolder values in MOSS 2007

Found something interesting when working on a customer’s request, so thought I’d share it!

A customer of mine wanted to get rid of the “Error: Access Denied” message that’s displayed to unauthorized (but authenticated) users in MOSS 2007/WSS V2. Instead, she wanted something like “Feel free to join this site”, which according to her organization would convey a more positive message to users.

I had a look at the AccessDenied.aspx page and as expected couldn’t find the text in question. Instead, there were content placeholders. This page uses the “simple.master” as its master page. Certain content placeholder IDs are overridden here. A few are “PlaceHolderPageTitle”, “PlaceHolderPageTitleInTitleArea”, “PlaceHolderMain” and the likes.

A quick solution would be to, remove the line:

<SharePoint:EncodedLiteral runat=”server” text=”<%$Resources:wss,accessDenied_pagetitle%>” EncodeMethod=’HtmlEncode’ />

And replace it with:

<SharePoint:EncodedLiteral runat=”server” text=”whatever text I want” EncodeMethod=’HtmlEncode’ />

Though this would work, this is not recommended. See 898631 for supported and unsupported scenarios in customization and custom site definitions.

Another way is to understand how resources work and try tampering with it (well, a copy of it actually). The overridden attribute is referencing a resource file. You would see something like:

<%$Resources:wss,accessDenied_pagetitle%>

The above syntax indicates that we need to look into wss resource file located *somewhere* and need to find the variable “accessDenied_pagetitle”. I searched for wss*.resx file on the server and got several of them. One under \12\config\resources and the others under \app_globalresources folder of the individual virtual directories created by MOSS 2007/WSS v2. Modifying the wss.en-US.resx file under \12\config\resources wouldn’t reflect the change in the UI. This would also mean we are modifying the default OOB files and is not recommended. We can modify the wss.en-US.resx file under \app_globalresources and that would reflect the changes. Every time a new web application is create the resource files are copied over to \app_globalresources and they govern the resource part of that application. Pop open the wss.en-US.resx under \app_globalresources file and look for the variable “accessDenied_pagetitle” in it. There would be a data name/value pair. You should see “Error: Access Denied” in the value attribute. This can be changed to any text we want the users to see.

You’ll also see wss.resx file. If you have a wss.en-US.resx (the en-US part can vary depending on the language), you'll need to use that. If you don't, you can use wss.resx. But, if both wss.resx and wss.en-US.resx (or any other language file) are present, wss.en-US.resx would take precedence. I haven't tried a scenario where you have multiple languages installed. But, I believe we should make changes to the language file that the site uses.