Displaying a links list in the CQWP (SP2010)

I got a message from a pal (@AndrewJolly) asking if I knew anything about displaying the contents of a Links List in the Content Query Web Part (CQWP). I vaguely remembered having had some difficulties with this in the past so I thought I’d take a quick look into it. The good news is that it is possible to get it to display as expected, without having to resort to any custom code or XSL!

CQWP Links List Displayed Correctly

How to do this? Well first let me run through the steps I tried. Firstly creating a quick links list on an out of the box publishing site and adding a few entries.

Now, adding a CQWP to the page and simply configuring the query to point at my particular list, and setting the display style to ‘Bulleted title’, and I get this strange list of blank links. Huh.

CQWP Blank Titles

Figuring that this is showing ‘(blank)‘ because the list item content type has a hidden title field, which therefore doesn’t get populated, I looked at changing the configured slots on the web part. What are slots? Slots are a great new feature of the SharePoint 2010 content query web part which allows you to match different fields to the variables used in the XSL – therefore giving you an extra degree of separation between the presentation and the data; and allowing for greater re-use.

Configuring the slots is as easy as adding the column name into the Fields to display section. So configuring the slots to use the URL column for the title I tried again. At the same time, I also pointed the Link slot with the URL column as the previous attempt linked me through to the display form of my list item – not the actual link I’d entered.

CQWP Fields To Display With URL

Giving:

CQWP Full URL For Titles

So close! But still not quite right. The link is now working as expected, i.e. taking me through to Bing or Google etc, but the display is not correct. By taking the URL column out of the Title slot and leaving it blank I can have the full URL displayed (which may even be desired in some scenarios) – but this is still not what I’m really after.

CQWP Just URL For Titles

Taking a step back and looking at this and it seems clear that the root cause of my problem is that the value that I’m looking for, e.g. just the link title, is not stored in its own column; rather it is one part of the whole link column. In the past I’ve addressed this and similar issues by creating my own presentation style in custom XSL – see my extended content query web part post.

Without wanting to create custom XSL for such a simple request I looked at other options. Looking at the root cause then it seems that the simplest option is to add in the title of the links into its own column! I used the existing Notes column for this, all though it would be just as easy to add a new column to your list and use that.

So (nearly there now) by adding in the title data into the Notes column in my links list, and now setting the title slot to use that column we get the links list displayed in the content query web part as we’d have expected it to!

CQWP Fields To Display With Notes

share and enjoy
  • Print
  • Twitter
  • Digg
  • del.icio.us
  • StumbleUpon
  • Yahoo! Buzz
  • Google Bookmarks
  • Facebook

14 comments to Displaying a links list in the CQWP (SP2010)

  • Mohammed Sufiyan

    Hey Glyn Hi,
    Hope you doing good!!!!!
    hey Glyn I have the same problem!!!!!
    Can u explain me a bit about Fields to display!!!!!
    ?

    • Hey,

      The Fields to Display is a setting in the properties of the web part. If you simply edit the web part you’ll see it as per the screenshots in this post. I think it’s under the Presentation section of the properties.

      Thanks,

  • David Dennis

    Thank you very much. Very, very rare that something works the same way in two SharePoint environments. This will save me a tonne of heartache with the client. Well written explanation and a great display tool for those of us that aren’t developers.

  • Joe

    It’s a shame Microsoft have kept the url and description (i.e. URL title) in the same field. It’s always been hard to crack that open but it is possible. The CQWP is such a powerful webpart and is slightly improved in 2010 but it still isn’t as good as it could be!

  • Joe

    Just to add that using the Notes column to add the title is more of a hack than a solution. Ok it works, but users won’t like it!

    • Hi Joe – I’d prefer to say that it’s working within the constraints of the system rather than a hack 😉

      But seriously, I don’t quite agree that we can say a thing like “users won’t like it” because it depends on the scenario. If the ongoing maintenance and ease-of-use was the largest factor when putting together a solution then I’d go down a custom XSL route. However, if it’s simply to meet a one-off requirement then I think this approach (and approaches like this) are fine as users will be more likely to compromise in the interests of time to deliver and achieving the end-result.

      Thanks

  • Nadine

    Thanks Glyn! This solved a second issue I was having when linking to internal lists, in that the link would open the form and not the list itself. Causing users to have to click twice to get to the information (small issue, but still a pain).

    I was just using the Title field but swapping that over to URL [Custom Column] you’ve mentioned above resolved that. (Maybe a no-brainer to you but, being new to SP, this was giving me some slight angst!)

    Thanks!

  • Torey

    I am trying to use the Links webpart and want to actually have each item in the list automatically have a bullet. It would be * Link 1
    * Link 2
    * Link 3.

    Is there an easy way?

    • Hi Torey – if the out of the box styles don’t do what you want then it’s often the case that you probably need to go ahead and create some custom XSL for your own presentation style – although in your case it may be possible to achieve the same with just CSS perhaps? (which you could include on the page with a content editor web part if you don’t have access to the main branding assets).

      HTH

  • Luke

    Hi Glyn

    did you create URL site column thus it’s placed in Custom Columns ?
    I’m using OOB URL from Base column and I cannot use in the Presentation section-> Fields to display in field Title Notes it’s changing me to About Me :/

  • Jay Brooks

    Glyn, your post saved me a lot of time. Your solution worked great… I’m using a CQWP to get Audience Targetting to work (sigh). Anyway, loved the post and thanks. How did you get bullets on your list? That wasn’t an appearent option in my styles dropdown in the web part options.

  • […] post “Displaying a links list in the CQWP” hielp mij herrineren hoe het ook alweer zat met een […]

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>