Master Pages and Relative Logos
We have one master page that is used through out our site collection containing one top level site and a large number of subsites.
One of the problems we faced was that each of the sub sites had their own logo to display. Infact the subsites needed to show two logos, one from the top level site on the right hand side and one from the sub site itself on the left hand side of the header. The top level site contained only one logo. For obvious reasons we were keen that whatever the solution may be, the site collection should use the same master page through out. We also didnt want to be in a situation where we would have to go to each sub site and make the changes (Site Settings > Title, Description and Icon) to reflect the correct logo.
That's when we discovered how useful the ~Site token could be. ~Site gets the link to the current site-relative path. This helps me determine which site my user is currently navigating, be in the main site or any of the subsites within the collection.
Next step was the logos themselves. All the logos appearing on the left were renamed logoleft.gif and all the logos appearing on the right were renamed to logoright.gif. Also made sure that the logos were all of the same height and width. Created an image folder in each site, and uploaded the appropriate logos.
Replaced
<SharePoint:SiteLogoImage id=”onetidHeadbnnr0″ LogoImageUrl=”/_layouts/images/titlegraphic.gif” runat=”server”/>
with
<asp:Image runat="server" id="imglogoleft" imageurl="<%$SPUrl:~site/images/logoleft.jpg%>" width="250" height="50"/>
to display the logo on the left of the header. Added another <asp:Image> tag for the logo appearing on the right.
Finally, the top site did not require a logo on the right hand side, but this approach forces the use of an image. Not uploaded one will cause Sharepoint to look for a logoright.gif when its not there and render an empty image box. So we uploaded a pixel gif having the same background as the header to solve the problem.
Next time the Sharepoint Administrator decided to create another subsite, all (s)he has to do is upload logos with predefined names to a predefined location on the site.