Content Query Web Part (CQWP)

Page copy protected against web site content infringement by Copyscape

I had a requirement to show the top 3 of news listing on the home page with the option of having these links open up in a new window.

First read these 2 good articles

http://blogs.msdn.com/ecm/archive/2006/10/25/configuring-and-customizing-the-content-query-web-part/

http://www.heathersolomon.com/blog/articles/customitemstyle/

Now, when it comes to locating the internal name and the field type, you may encounter some issues. Refer to Heather Solomon blog where she has some pointers.

1) Create a site column named "OpenInNewWindow" and make that a choice type with values "true" and "false"

2) Create all other site columns as required.

3) Include the site columns in your custom list.

4) Edit ItemStyle.xsl and include the following lines in your template section

        <xsl:variable name="LinkTarget">   

<xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>

        </xsl:variable>

 

You will then be able to use this variable in your <a href> reference target target="{$LinkTarget}"  

Once you create a new item in your list and set the OpenInNewWindow variable, the link will open in a new window if value is set to "true".