July 11, 2007

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.

July 3, 2007

Using Querystrings in DataForm Webparts

One of the customisations we did for a recent Sharepoint project was to filter a Data Form webpart based on values supplied from the Querystring.

To make your DataForm accept values from the Querystring, try the following:
1. Open your Sharepoint site using Sharepoint Designer.
2. Create a new page and drop in a DataForm webpart.
3. Bind the DataForm webpart to any of the available lists.
4. Now switch to the Code view and locate the HTML code rendering the webpart control. Under the <ParameterBindings> tag, look for
<ParameterBinding Name="filterParam" Location="Postback;Connection"/>
5. Change this to
<ParameterBinding Name="filterParam" Location="Postback;Connection;QueryString(myField)"/> where myField is the name of the Querystring paramater you want to supply.
6. Now, switch back to Design view, select the DataForm webpart, and open the "Data View" menu (Alt+D) and select the Filter.
7. A filter criteria box shows up. Choose the column that needs filtering in "field name" and select [Input Parameter] in Value and close the filter dailog box.

The Dataform webpart will now be ready to accept values from the querystring. To test this, load the page and pass a querystring.
http://mysite/samplepage.aspx?myField=xxxx

July 2, 2007

MOSS 2007

I had not heard too many good things about Sharepoint 2003, so when a new client approached us and asked if we could create a Sharepoint site for them in the new version, I was a little bit apprehensive to start with.

However since we had never worked on this technology we were also excited about doing this project. We went through a decent learning curve over a 4 week implementation period and I quite enjoyed the experience. For one thing, it looks like MOSS 2007 is a vast improvement over its predecessors. I would'nt rehash the improvements here as there are plenty of links on the internet that delve into exactly that.

In my spare time what I would like to do is try and document some of the interesting customisations that we implemented in Sharepoint. Many of them have already been discussed before at various forums or blogs, nevertheless I hope this blog will serve to be a point of reference and in due course be of some help to others.