Creating a staff Directory in SharePoint Part 2 - People Search

In part 1 we looked at creating a Staff Directory using the User Information List. This time we'll attempt it with the People Search.

To begin with obviously we need to be able to search find people using the search. I have already set up a site using the Search Center  site template. The only problem is I am getting no results when searching for people.



I followed these instructions. - http://groups.google.com/group/microsoft.public.sharepoint.portalserver.development/browse_thread/thread/6f01af3e9da9e0b2/3caa0e3d6d1237c1

and it now works.

 



The first thing we can explore is what happens when we click edit on the page. Remembr that the search results page is actually a publishing page which is why it sits in a /pages directory.

 


Looking at this page in edit mode can provide some insight into what all those search web parts in the web parts gallery do. The capabilities of this page are beyond the scope of this article but will definitely be revisited in another article.

One of the requirements of the staff directory is that users should be able to click on a letter like this..

 

This was easily achieved by modifying the script found here - http://www.ramonscott.com/wordpress/?p=8

to look like this.

 

peoplesearch.txt (1.85 kb)


Next we want to customise the layout of the search results themselves. As with most of the web parts you will need to edit the XSL. Before you do though note that there appears to be a bug that throws an error every time you edit the XSLT. You can ignore it but unfortunately you can't see any changes you make until you publish the page. More info here - http://www.sharepoint-tips.com/2007/04/error-item-with-same-key-has-already.html

Instructions on customisation can be found here - http://www.sharepointology.com/development/customize-the-people-search-results-part-1/ and here - http://www.sharepointology.com/development/customize-the-people-search-results-part-2/

I was going to provide some of these instructions myself but these articles explain them really well.

Just to add a few finishing touches we can adjust the search dropdown options by mofidying propeties of searchbox.

 



I added favourite Cake and it now looks like.

 

Editing skins with SharePoint Designer

7. April 2009 08:56 by sashashev in reskining, SharePoint Designer  //  Tags: , ,   //   Comments (0)

Editing skins with designer can be frustrating due to the many quirks in the process.

For a good starting point read here - http://www.sharepointblogs.com/tigirry/archive/2007/07/27/easy-way-of-editing-customized-theme-in-moss-2007.aspx

Some additional tips.

After you edit CSS files don't swich themes until you copy all your changes back to the theme.css file in the 12 hive otherwise SharePoint will overwrite your changes.

Every time you change themes SharePoint puts a local copy of the theme folder copied from the 12 hive which overwrites the current themes folder.

Only 1 theme folder per site collection appears in Designer.

Also as an extra note in the Masterpage section of sesttings, the system Masterpage option is used for the document center masterpage.

It appears the difference between the SIte Master Page and System Master page is primarily the quick launch. Which becomes the treeview in the System Page.

 

 

 

How to customize a Sharepoint theme

31. March 2009 16:29 by sashashev in reskining  //  Tags: , ,   //   Comments (0)
In this article, we are going to explore how to modify an existing Sharepoint theme.  This process is pretty straight forward and this article provides a few tips and tricks along the way.  Please note this process requires some previous CSS experience.

Copy the theme directory you want to customize

 

1.    Navigate to THEMES folder:  %Program Files%\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES.  Copy theme folder you want to modify and rename the copied folder.  Here, we copied the BREEZE2 folder and renamed it to DERWENT.

 

Update the copied files with the new theme information

2.     Navigate into the new theme folder and rename the .INF to the name of the new theme.  Here we renamed BREEZE2.INF to DERWENT.INF.

 

 3.     Open the INF that was just renamed and update all the entries with the new name of your theme.  A global search and replace (Ctrl+H in most editors) will take care of this easily for you.  Here we changed all the Breeze2 entries to Derwent.

 

 4.    Next, we need to add the new theme into the XML file so that Sharepoint knows it exists.  To do this, we are going to edit the SPTHEMES.XML file located in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033.   Add the following <Templates> entry into the XML file:

For now, leave the <Thumbnail> and <Preview> tags as they are, we will get to these later.  They simply specify which images will show up when the user is previewing a theme.  Since we don’t have a screenshot of our new theme yet, we do not have anything to put here.  Your XML file should look similar to the one below:

Make CSS changes to the theme

5.    Next, we are going to edit the theme.css style sheet located in the new theme folder (for example, C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES\DERWENT\theme.css).

This is where all of the hard work comes in.  In order to work more efficiently, it is a good idea to save a couple of the Sharepoint pages locally (File -> Save As… from IE, select Webpage, complete (*.htm;*.html) for Save as type).  

 

This will allow you see the CSS changes on a local page without have to perform an iisreset (See Step 6) on the server.

For the pages I saved locally, the .htm files seemed to link to “Derw1011-65001.css” style sheet instead of the expected theme.css file.  It turns out the “Derw1011-65001.css” is actually a copy of the theme.css style sheet.  (The “65001” in the filename comes from the codepage setting in the .INF file).  So when you save a page locally, it will also save the “Derw1011-65001.css” file since the .htm file links to this file.  Edit the “Derw1011-65001.css” file locally and once you’re happy with the changes, copy the contents of this CSS file into the theme.css file located on the server (after making a backup, of course).

Microsoft has provided some documentation (http://msdn.microsoft.com/en-us/library/ms438349.aspx) on the CSS classes used in core.css which shares some common CSS classes with theme.css, however I found it easier to examine the CSS information using IE Web Developer or Firebug.

Force Sharepoint to recognize changes

6.    Now that you finished with your CSS changes, you need to perform an iisreset from the command prompt in order for the Sharepoint server to recognize the changes.   

To do this, start the command prompt (Start -> Run… -> type cmd -> Enter).

   Type iisreset, then hit enter. 

Note: be careful performing this command on a server in a production environment as it will sever any active connections to all of the websites being hosted on the server.

Apply customized theme to site

7.    Next, we are going to apply the newly created theme.  Open a browser and navigate to the Sharepoint page that you want to apply the new theme to.  Click Site Actions -> Site Settings.

 Once in Site Settings, click “Site Theme” from the Look and Feel section:

This will bring up a list of all available themes that you can apply to the site.  You should see the theme we added in the previous steps.  Below, you can see the Derwent theme we added in the example:

Highlight the theme you added, and click apply. 

Update preview image

8.    Notice the Preview image shown to the left of the list of themes.  You will still see the preview image of the copied theme.

In order to update that image with a preview of our own theme, we need to grab a screenshot of our new theme and add it to the proper location.

Navigate to the home page of the site you changed the theme for.  In our example, we would navigate to the My Home page.

Take a screenshot of this page and resize it to about 350 x 230 pixels using your favorite image editor (i.e. SnagIt). 

Save the screenshot in a standard format (.gif, .jpg, or .png).


9.    Next, we need to add the image to the Sharepoint server so that the image will appear when a user is attempting to select a theme.

Copy the screenshot image you created in Step 8 into %Program Files%\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES.  Here you can see I’ve named my screenshot Derwent_Preview.gif:

 10.     Repeat Step 4, updating the <Preview> and <Thumbnail> attributes in the SPTHEMES.XML file with the new name of your preview image, as shown below:

11.     Repeat Step 6 to complete the changes on the Sharepoint server.

12.    Next, we need to see our changes on the Sharepoint site.  Repeat Step 7 to navigate to the Site Themes Settings Page.

Notice that the image you just created isn’t showing up in the preview?  In order to see the changes you just made to the theme, you must first apply another theme (any theme listed - it doesn’t matter which one), and then reapply the new theme. This is required to see ANY changes you have made to theme, if you already have the theme applied.

Creating custom landing pages in SharePoint Part 1 - TheTable of Contents Webpart

The mission: Create a default landing page for each publishing site to aid in navigation.

The landing page should contain 2 sections.

  1. A section that lists all sites directly below the site you are on (1 level)
  2. A section that lists all the pages in the pages folder.
To pretty things up we may want to show images and/or descriptions for sites and pages.
The images and descriptions should be pulled from the image and description field the user enters when creating the new subsite or page.

Method No 1- Using the Table Of Contents Webpart

Note: Please read conclusion of this article to see why this solution didn't meet my requirements.

An obvious place to start is to see what we can do using the built in Web Part purpose built for our task.

The table of contents webpart provides a quick an easy method to display a Table of Contents. (Believe it or not)

It has cool features such as..

  1. Pick from which level to start the TOC
  2. Style your TOC 
  3. How many levels to show


More on the TOC web part can be found here and here

As we want this page to be a template with the contents starting from the current site we use SharePoint Designer.

Page templates reside in the same folder as Masterpages. 

_catalogs >  masterpage

  

To keep things seperated I have created 2 subfolders. Custom > Layouts and my new layout page is called WelcomeTOC.aspx.

I created this page by making a copy of one of the existing Welcome Pages.(I can't remember which but any layout will do)

I then added a TableOfContentsWebPart into the first WebpartZone. I'm not sure whether you need the ZoneTemplate tags.

<ZoneTemplate>
<PublishingWebControls:TableOfContentsWebPart runat="server" 
Description="" 
NoDefaultStyle="" 
AllowZoneChange="True" 
ViewContentTypeId="" 
AllowHide="True" 
ChromeType="None" 
UseSQLDataSourcePaging="True" 
AllowRemove="True" 
Dir="Default" 
AllowConnect="True" 
PageSize="-1" 
HelpMode="Modeless" 
Title="Table of Contents" 
PartOrder="1" 
ID="g_c8cdaea8_bb45_4983_afc7_bfcd74aa22dd" 
MissingAssembly="Cannot import this Web Part." 
FrameType="None" 
IsVisible="True" 
DetailLink="" 
ZoneID="TopColumnZone" 
ConnectionID="00000000-0000-0000-0000-000000000000" 
PartImageSmall="" 
PartImageLarge="" 
HelpLink="/_layouts/help.aspx" 
ShowWithSampleData="False" 
ExportMode="All" 
IsIncludedFilter="" 
HelpUrl="/_layouts/help.aspx" 
DataSourceID="" 
IsIncluded="True" 
ExportControlledProperties="True" 
FrameState="Normal" 
AllowEdit="True" 
AllowMinimize="True" 
SuppressWebPartChrome="False" 
AnchorLocation=""
__MarkupType="vsattributemarkup"
__WebPartId="{C8CDAEA8-BB45-4983-AFC7-BFCD74AA22DD}"
WebPart="true"
Height=""
Width=""
LevelsToShow="1"
DisplayColumns="2"
Level1Style="Vertical with descriptions">
<DataFields>
</DataFields>
<SampleData>
<Levels>
<Level LevelNumber="1" Path="/Site1" Title="Site 1" BeginColumn="true">
<Item LevelNumber="1" Path="/Page1" Title="Page 1" />
<Item LevelNumber="1" Path="/Page2" Title="Page 2" />
<Item LevelNumber="1" Path="/Page3" Title="Page 3" />
</Level>
<Level LevelNumber="1" Path="/Site2" Title="Site 2" BeginColumn="true">
<Item LevelNumber="1" Path="/Page1" Title="Page 1" />
<Item LevelNumber="1" Path="/Page2" Title="Page 2" />
<Item LevelNumber="1" Path="/Page3" Title="Page 3" />
</Level>
</Levels>
</SampleData><Xsl>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:cmswrt="http://schemas.microsoft.com/WebPart/v3/Publishing/runtime" exclude-result-prefixes="xsl cmswrt x"> 
<xsl:import href="/Style%20Library/XSL%20Style%20Sheets/Header.xsl" /> 
<xsl:import href="/Style%20Library/XSL%20Style%20Sheets/LevelStyle.xsl" /> 
<xsl:import href="/Style%20Library/XSL%20Style%20Sheets/TableOfContentsMain.xsl" /> </xsl:stylesheet></Xsl>
</PublishingWebControls:TableOfContentsWebPart>
</ZoneTemplate>

The important thing to note here is the

AnchorLocation="" attribute.
This sets the starting location of our links to the current site.
Customising the layout

Customising the layout is similar to customising the layout for other web parts such as the RSS reader or Custom Query web part. You need to do some XSLT.

You can edit 3 files

  • Header.xsl
  • LevelStyle.xsl
  • TableOfContentsMain.xsl

These files reside in Style Library > XSL Style Sheets

  

You can read more info here -

http://panvega.wordpress.com/2009/02/11/customizing-styles-of-table-of-contents-webpart-toc/#more-920

 

Conclusion

Basically you can alter the layout but the TOC web part is very limited as it only outputs the @Title, @Description, @LevelNumber and@Path.

This is OK if you just want some basic text but this won't cover our needs to display a possible image for each site or page listed.

A neat trick for verifying this is to add the following to your XSLT transformation in the LevelStyle.xsl file.

This will output the raw XML in between the <rawdata> tags.

That way you can see all the data you have to play with. I suspect this will work in the other xsl files in Sharepoint.

   <xsl:template name="ShowAll" match="Level[@LevelTemplate='ShowAll']">
  <rawdata>
    <xsl:copy-of select="*"/>
    </rawdata>
</xsl:template>

When you view the source of your page you will something like..

<rawdata>
<Item Description="I am happy to announce " LevelNumber="1" Path="/News/Pages/mypage.aspx" Title="Title of my page"></Item>
</rawdata>

Further reading:
Customizing Styles of Summary Links, Table of Contents, and Content Query Web Parts

Webcoda, SharePoint Consultants & Web Development

SharePoint Development Sydney is a crack team of SharePoint Consultants and SharePoint Developers.

We can't tell you their names or show their faces on TV but if you need a SharePoint job done right, call them on +61 2 9370 3602 or email us at info@sharepointsydney.com.au

Persecuted by the Government and shunned by society they developed their SharePoint skills in back streets and labor camps where other programmers wouldn't dare to tread. 

During a trek through the Himalayas they stumpled upon the fabled Mossy Yak who shared his SharePoint knowledge of how to attain Nirvana through a series of Workflows and Event Handlers. Their mission is to spread this knowledge through-out the world to bring peace, harmony and document version control to all .

 

Month List