For lack of a better name: blog

16Oct/101

Open items in dimmed layer from CQWP

When you query list items with the Content Query Web Part you sometimes want to open it in a dimmed layer instead of a new full page. This is much more user friendly.

I found out it is really easy to achieve this functionality. So what we want is:

image

And when we click a item this is opened in a dimmed layer:

image

How to

1. Open SharePoint designer and go to the style library.

2. Open the file ItemStyle.xsl in the folder XSL Style Sheets (don’t forget to check the file out).

3. Copy a section from <xsl:template …> to </xsl:template> that you want to use as the base for the new styles. In this example I copied the TitleOnly template.

4. Rename the style so it has a unique name, ie:

<xsl:template name="TitleOnlyDimmed" match="Row[@Style='TitleOnlyDimmed']" mode="itemstyle">

5. The old link looked like this:

<a href="{$SafeLinkUrl}" title="{@LinkToolTip}">

Remove the href and add the following:

onmouseover="javascript:this.style.cursor='hand';"  onclick="javascript:SP.UI.ModalDialog.ShowPopupDialog('{$SafeLinkUrl}'); return false;"

the row will look like this:

<a onmouseover="javascript:this.style.cursor='hand';" onclick="javascript:SP.UI.ModalDialog.ShowPopupDialog('{$SafeLinkUrl}'); return false;" title="{@LinkToolTip}">

The first will make sure the user has the idea it is a normal link and gets a hand as cursor. The second will open the url (SafeLinkUrl) in a dimmed layer.

6. Save the file and check it in.

7. Go to the CQWP and select the newly created style under presentations –> itemstyle.

That’s it. When clicking the link, the list item will be opened in a dimmed layer.

More info?

MSDN: http://msdn.microsoft.com/en-us/library/bb447557.aspx

Posted by Alexander Ketelaar

Comments (1) Trackbacks (0)
  1. This was an awesome post. I searched for hours trying to find this!

    Thank you,
    Rene


Cancel reply

(required)

No trackbacks yet.