Master Pages Tokens

Hi guys, It’s a little post, but I thought it would be useful for beginners to SharePoint branding.
“Master Pages” is an essesntial topic when it comes to SharePoint Branding as they provide consistency by providing a common layout, content, look and feel across the pages that use them.

Note the reference to the token ~masterurl/default.master in the first line in any sharepoint content page.

When you use the attribut MasterPageFile into your page header, you can give the relative url of the master page you want.
There also some token to give you more options :
Dynamic token :
“~masterurl/default.master”>>> This token references a master page from a content page by using the MasterPageFile attribute together with the value of the MasterUrl property. And this resolves by default to /_catalogs/masterpage/default.master but you can change the MasterUrl property using SharePoint designer or using Master Page page under Site Settings via the browser .
“~masterurl/custom.master”>>> This token references a master page from a content page by using the MasterPageFile attribute with the value of the CustomMasterUrl property . Also it resolves to /_catalogs/masterpage/default.master by default.

MSDN Note : If you subsequently need to delete the default.master file, you must set both of those properties to a different value.
Static token :
“~site/x”>>> This token link to the current site-relative path
“~sitecollection/x”>>> This token link to the current site collection-relative path

For example, if your content page is located at http://myPortal/subsite1/subsite2/default.aspx and you use the token “~sitecollection/mypage.master”, your content page would use the master page athttp://myPortal/mypage.master. If you use the token “~site/mypage.master”, the content page would use the master page located at http://myPortal/subsite1/subsite2/mypage.master .

Tip : It’s also possible to control the selection of Master Pages at run time with .NET code using the page’s OnPreInit method or by using an HttpModule. ( will be discussed in later posts ) .

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s