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.
Comments
Anonymous
April 14, 2007
PingBack from http://www.decatec.it/blogs/2007/04/15/Customize+MOSS+Placeholders.aspxAnonymous
June 06, 2007
Hi--I need to completely rebrand (not just change the text) of the access denied page. I found the access denied page in my dev environment as well and then I thought: I won't have access to the 'program files' folder in the live environment. The live environment is shared hosting. Also, i can't find the simple.master you mention. simple.master might be another option if i could find it. Thoughts, anyone?Anonymous
March 22, 2008
How to use <%$Resource in moss 2007 webparts ?Anonymous
March 15, 2009
vamsi check out this link http://www.mikhaildikov.com/2007/03/sharepoint-resources-types-use-and_2163.htmlAnonymous
July 22, 2009
Modifying the resource file could damage the whole site. Take back up before doing anything like that..Anonymous
June 22, 2010
This method assumes every site on a virtual directory wants the same replacement for access denied so this solution doesnt work for me.