Marie Kristin Johansen - sharing what I have experienced
Tuesday, July 28, 2009
The SharePoint team has posted som videos showing some of the new features in SharePoint 2010.

The videos can be found on the new SharePoint 2010 web site.


I can't wait to get my hands on this!
Tuesday, July 28, 2009 11:21:50 AM (W. Europe Standard Time, UTC+01:00) | Comments [0] | SharePoint 2010#
Saturday, January 24, 2009

Yes it is possible:) All you have to do is alter the properties of your Content Query Web Part. To be able to do this do the following:

1. Eksport your content query web part.

2. Localise the "CommonViewFields" property in your web part. This should look someting like this:

<property name="CommonViewFields" type="string" />

3. Replace this line by this:

<property name="CommonViewFields" type="string">Topic,Lookup;</property>

Where "Topic" is the internal name of your column.

4. Localise the "AdditionalFilterFields"

<property name="AdditionalFilterFields" type="string" null="true" />
5. Replace it with the following line:
<property name="AdditionalFilterFields" type="Lookup">Topic</property>

6. Save your web part, upload it an drag it on to your page. Check to see if the column is visible in the filter drop down.

Saturday, January 24, 2009 7:52:05 AM (W. Europe Standard Time, UTC+01:00) | Comments [0] | #
Wednesday, December 17, 2008
For some time we have struggled with getting workflows created in SharePoint Designer to work when using these in Site Templates. Luckily we found a blog post having a solution to the problem SharePoint designer workflow association stsadm repair command written by Emile Bosch.

Using this solution combined with a Feature Receiver running the stsadm command: -o repairworkflowassociations -url http://yoursite fixed the problem. Be aware that the user running your SharePoint application also needs to have access to start the processes. It is not possible to use imperonation since the Process.Start() method uses the parent process user no mather what. Trying to do this will give you an Access Denied error message.

Here is the code for running stsadm command in code:
public class RepairWorkflowAssociations : SPFeatureReceiver
{
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
string prgFilePath = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles);
string stsadmPath = prgFilePath + @"\Microsoft Shared\web server extensions\12\BIN\stsadm.exe";

System.Diagnostics.Process proc = new System.Diagnostics.Process();

//Set the process properties
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = stsadmPath;
proc.StartInfo.UseShellExecute = false;
string strWebUrl = SPContext.Current.Web.Url.ToString();
string strOpertation = "-o repairworkflowassociations -url ";

proc.StartInfo.Arguments = String.Format("{0}{1}", strOpertation, strWebUrl);
proc.Start();

//
Wait for the end of the process
proc.WaitForExit();
}
}

We use activate this feature in a custom site creaton method but it will work just as well using feature stapeling.

Wednesday, December 17, 2008 11:37:55 AM (W. Europe Standard Time, UTC+01:00) | Comments [0] | Features | SharePoint | Workflows#
Tuesday, December 09, 2008

The other day a customer of mine requested a list of links from a link list grouped by topics, where when clicking the link title you got the description of the link expanded below.

To do this I used a content query web part with a custom ItemStyle and a content editor web part as a container for the JavaScript.

In the ItemStyle template as shown below we first had to split the link returned from the link list. This contains of the URL and the title formatted as "URL","title". I created two variables, one for the Title (Target) and one for the URL (LinkUrl). To get these I used those substring-before and substring-after functionality in xsl.

After creating these variables I created a link tag for displaying the Title ($Target) with a onClick starting a JavaScript function called showInfo('{$Target}') taking the xsl variable "Target" as input value.

To be able to match the description and the title clicked I had to create a dynamic id for the div tag displaying the description. This is done using a xsl:element with xsl:attribute elements. The id attribute of the div tag is set to the target variable. This to match the input in the JavaScript function and the description block. The div also get a style attribute to be able to dynamically hide and show the contents of this div when clicking the title of the link.

At the end of the style we display a text redirecting to the actual source page by using the LinkUrl variable.

Here is the full template witch should go either in the ItemStyle.xsl file. I usually create a custom ItemStyle.xsl for my customers and deploy this as an feature to avoid tempering with the original xslts, but this is up to you.

<xsl:template name="LinkList" match="Row[@Style='LinkList']" mode="itemstyle">
     <xsl:variable name="DisplayTitle">        
      <xsl:call-template name="OuterTemplate.GetTitle">
             <xsl:with-param name="Title" select="@URL"/>
             <xsl:with-param name="UrlColumnName" select="'URL'"/>
          </xsl:call-template>    
     </xsl:variable>
     <xsl:variable name="LinkTarget">
             <xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
     </xsl:variable>
     <xsl:variable name="Target">
      <xsl:value-of select="substring-after($DisplayTitle,', ')"></xsl:value-of>    
     </xsl:variable>  
     <xsl:variable name="LinkUrl">
      <xsl:value-of select="substring-before($DisplayTitle,', ')"></xsl:value-of>    
     </xsl:variable>    
            <div id="linkitem" class="item" >
                  <div class="link-item">
                      <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>                                                  
                      <a name ="{$Target}" id="category" href="#{$Target}" temp_href="#{$Target}" onclick="showInfo('{$Target}');">
<xsl:value-of select="substring-after($DisplayTitle,', ')"></xsl:value-of>
</a> <xsl:element name="div"> <xsl:attribute name="id"> <xsl:value-of select="$Target"></xsl:value-of> </xsl:attribute> <xsl:attribute name="style"> display:none;color:black; </xsl:attribute> <br /> <xsl:value-of select="@Description"></xsl:value-of> <a href="{$LinkUrl}" temp_href="{$LinkUrl}"> Gå til denne siden.</a> </xsl:element> </div> </div> </xsl:template>

To Show / Hide the description we simply use the JavaScript below, hidden on the page by using a content editor web part. You can also put the script in the page itself or as a linked file.

First we find the div tag corresponding to the clicked link then we check whether the comment is collapsed or expanded at the moment and sets the style tag to the opposite.

And here is the JavaScript:

<script language="JavaScript">

function showInfo(link)        
{  
   var divs = document.getElementsByTagName('div');          
   //alert(link);

   for (var k = divs.length - 1; k >= 0; k--)
   {
      if (divs[k].id == link)  
      {  
         if(divs[k].style.display == 'none')
         {
            divs[k].style.display = 'inline';
         } 
         else 
         {
            divs[k].style.display = 'none';
         }         
      }
   }  
}
</script> 

Tuesday, December 09, 2008 5:41:26 PM (W. Europe Standard Time, UTC+01:00) | Comments [0] | Content Query Web Part | ItemStyle | JavaScript#
Tuesday, September 16, 2008

To be able to desploy the design created I usually end up with three basic features:

  • MasterPageAdder: Adds the masterpages, css-files and all the needed images to the right places on the server/solution
  • MasterPageSwitcher: Sets the default and custom masterpage file of a site to CustomMaster in code by feature activation.
  • MasterPageStapler: Activates the MasterPageSwitcher for all created sites in the portal.

Here is how my project usually looks in Visual Studio:

Here I have chosen to put my Custom.css file in the Layouts\styles folder where the default css in SharePoint (Core.css) aslo are. However in some cases it might be more valuable to put it in the Style Library so that competent users at your customer more easaly can find and change it if nessecary. If you chose to do this you should deploy it using the ProvisionedFiles.xml file.

The masterpage adder feature

Consists of four files:

  • Amende_dings.png: Preview image for the custom masterpage.
  • AmendeCustom.master: The new masterpage
  • ProvisionedFiles.xml: Puts the files where it belongs in the solution
  • feature.xml: Makes everything happen

The ProvisionedFiles.xml containes information abput where to find the masterpage where to put it in the SharePoint structure (_catalogs\masterpage). It looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="OSGMasterPages" Url="_catalogs/masterpage" Path="masterpage" RootWebOnly="TRUE">
    <File Url="AmendeCustom.master" Type="GhostableInLibrary">
      <Property Name="ContentType" Value="Custom Master Page" />
      <Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/Amende_dings.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/Amende_dings.png" />
    </File>
  </Module>
  <Module Name="PublishingLayoutsPreviewImages" Url="_catalogs/masterpage" IncludeFolders="??-??" Path="" RootWebOnly="TRUE">
    <File Url="Amende_dings.png" Name="Preview Images/Amende_dings.png" Type="GhostableInLibrary" />
  </Module>
</Elements>

The feature.xml refferences the ProvisionedFiles.xml so that the files get copied when the feature is activated, remember to change the GUID before using the feature.xml:

<?xml version="1.0" encoding="utf-8" ?>
<Feature  Id="42141f24-8ebb-4b9e-8283-8ee6e989bcce"
          Title="Custom masterpage adder"
          Description="Adds the custom masterpage to masterpage gallery"
          Version="1.0.0.0"
          Scope="Site"
          Hidden="False"
          DefaultResourceFile="core"
          xmlns="http://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="ProvisionedFiles.xml"/>
  </ElementManifests>
</Feature>

The masterpage switcher feature

The master page switcher contains of only one file, the feature.xml:

<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="54705b7b-3293-4afa-be3f-8d53e032c6ef"
            Title="Activates custom design (masterpage set to custom masterpage)"
            Description="Switches masterpage to the custom masterpage by setting default master and custom master to custom masterpage"
            Version="1.0.0.0"
            Scope="Web"
            Hidden="FALSE"
            xmlns="http://schemas.microsoft.com/sharepoint/"
            ReceiverAssembly="Amende.SharePoint.Branding, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e39ad163a2911e63"
            ReceiverClass="Amende.SharePoint.Branding.FeatureReceivers.DesignActivatorFeatureReceiver"
         >
</Feature>

This refferences an assembly where we can find the DesignActivatorFeatureReceiver, to find the ReceiverAssemply and the ReceiverClass I usually use Lutz's Roeders .Net Reflector. Excellent tool!

I will post the code for the feature receiver in a couple of days.

The master page stapler feature

This feature makes shure that all new sites created in the farm get the custom master page attached. It consists of two files; the feature.xml which indicates this is a farm feature, and an elements.xml describing what site templates are affected by this feature. In our case this is all of them. We therefor use the term "Global". For som strange reason the global term do not include the team site site template. We therefore have to refference this seperately using the STS#1 definition name.

Heres the elements.xml:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/" >
  <FeatureSiteTemplateAssociation    Id="1D8E532B-C354-43f0-89FF-10401F3C70CD"    TemplateName="GLOBAL" />
  <FeatureSiteTemplateAssociation    Id="1D8E532B-C354-43f0-89FF-10401F3C70CD"    TemplateName="STS#1" />
</Elements>
And here is the feature.xml file:
<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="B7685480-E85D-4cb0-A100-FB470DDE1768"
            Title="ActivateDesign Feature Stapler"
            Description="Staples the Master Page Activator feature to all Site Definitions (GLOBAL and SPS#1)"
            Version="1.0.0.0"
            Scope="Farm"
            Hidden="FALSE"
            xmlns="http://schemas.microsoft.com/sharepoint/"
         >
  <ElementManifests>
    <ElementManifest Location="elements.xml"/>
  </ElementManifests>

</Feature>
Again, please remember to change the GUID of the feature.

Deploying the features

I am still using the old school way to deploy these features using stsadm commands installing and activating the features. First I deploy the master page adder and test this by checking that all of the files are where they are supposed to be. I also change the masterpage manually to check that everything looks ok.

Secondly I switch back to the SharePoint default master and deploy the switcher feature. I test this by activating the feature on a number of sites.

At last I install and activate the farm feature and test this by creating a new site.

Tuesday, September 16, 2008 6:11:53 PM (W. Europe Standard Time, UTC+01:00) | Comments [0] | Design | Features | SharePoint#
Wednesday, August 06, 2008

This is the first of a series of blog posts regarding deploying custom masterpages, page layouts and css files to a SharePoint 2007 solutions. There are several other blogposts out there conserning this very same thing but I have still not found one addressing all of the issues I have had to solve. My travel through SP branding land has brought me to the possition of having one SharePoint solution with several different features that provides the new design seemlessly to your solution. This series of posts is meant to be a walkthrough on how to do this. The solution has been implemented on several servers and it is working without problems on all of them. I would therefore like to share my solutions for all of you strugling with the same issues I have come to experience during the last years.

The first post will provide a list of all the issues my solution addresses and some tips on how to develop a custom MasterPage with css that will not behave strangely later on.

List of what this solution provides

  • Masterpage, css and page layouts on normal portal pages  on creation (Part 1 & 2)
  • Design on public and private MySite (Part 3)
  • Design on Application pages (_layouts) (part 4)
  • Custom SearchBoxEx control, so that the drop down list are over the search input box (Part 5)
  • Custom Master page on Multipage Meeting Workspace (Part 6)

Creating a custom master page

I usually do all of my master page, page layout and css development in SharePoint designer. I do however delete the files I have used when creating these after the first deploy of my solution are tested and approved.

First of all, please do not customize the default.master that you find in the _catalogs/masterpages folder in SharePoint designer. If something goes wrong you easally want to return to this master page, you also want to stay in supported state. Instead you should create a new master page file and copy the contents of the default.master into this one. I know alot of you probably will be using Heather Salomons minimal master. I have tried doing this but not with the best result. This walkthrough would therefore be about how I create my own minimal master. The issues I have experienced with Heathers minimal master is that large web parts are floating out of the page due to the lack of the boarder content place holders in the master. I always keep all the placeholders where they are and just set them to visible="false" if I dont use them in my design. This approach has not yet introduced any bugs to my solutions.

Now you should have a new masterpage with your own name. The next step will be to  crate a css. I usually like to create this in the StyleLibrary in SharePoint Designer to start with so that I have easy access to it. To link this new css to your master page past the following line into your master page in the <HEAD> tags.

<link href="/StyleLibrary/MyCustom.css" type="text/css" rel="stylesheet" />

It is also possible to reference your css using CSSRegistration and that should be just as good as doing it my way.

Next I start stripping the colors of my MasterPage by setting all the backgroud-colors in my css to transparent. To do this I use IE Developer Toolbar extensively to find the css classes I need to copy from CORE.CSS and into my own MyCustom.css. You can download the IE Dev Toolbar from here if you do not already have it:

http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038&displaylang=en


This might be a timeconsuming job, but remember that you just need to do it once. Use your minimal master for all the projects in the future as well. When this is done it is time to look at the more carectaristic design elements, such as header, footer background colours/images, font colour/size etc.. This should be rather time consuming, but I recomend using Heather Salomons geniuos reference chart for the css-classes in SharePoint. This can be found here:

http://www.heathersolomon.com/content/sp07cssreference.htm

The top banner of the page do most of the time have some kind of picture or at least background-color. To easy apply this in my master I usually put all the tables in the header in a new table and set the background settings on this one. Works like charm. Hopfully you now have a well functioning custom master page. Test it by changing to this master on one of your portal pages. In the next part of this series I will show how this masterpage can be added to a SharePoint portal with features.

Wednesday, August 06, 2008 1:34:42 PM (W. Europe Standard Time, UTC+01:00) | Comments [0] | Design | Features | SharePoint#
Wednesday, May 28, 2008
First of all, welcome to my blog!

This is the first of hopefully many blog posts on this blog. The content will mainly contain SharePoint related content. Both tecnical and more soft aspects of SharePoint projects. Today I had my first real experience with the use of Topic Maps in SharePoint, wich I found very interresting. I therefore thought it would be cool to share some of the information that was brought to me. I will probably post a lot more information on this topic when we start the implementation.


Wednesday, May 28, 2008 5:01:50 PM (W. Europe Standard Time, UTC+01:00) | Comments [0] | #
Thursday, May 01, 2008
Hi,

My name is Marie Kristin Johansen and i work with SharePoint solution for Amende AS in Oslo, Norway. I've been doing this since the release of MOSS 2007. Every day I seem to face new challenging both when configuring and developing in SharePoint environments. I would like to use this blog to share tips and triks I learn along the way with other SharePoint developers struggeling with the same things as me.

Marie

Thursday, May 01, 2008 11:37:00 AM (W. Europe Standard Time, UTC+01:00) | Comments [0] | About Me#
Search
Archive
Links
Categories
Admin Login
Sign In
Blogroll
Themes
Pick a theme: