A small problem with the content query web part is when you connect it to a link list is that it doesnt know what is the title of the link, and the link it is rendering point to the list item view page and not to the target of the link:
Connecting a CQWP to a link list
The web part renders (blank) as title, and the link points to the item
To fix this, we need to do two things:
Begin by connecting a query webpart to a link list like shown in the images above. Make sure there are some links in the list so you can track the change.
After this, you should get the same look that you saw in the second image above.
Export the web part - open the edit menu of the web part, and choose export to save it:
After you save it to the hard disk, open it for editing in your text (or xml) editor of choice (notepad is ok):
In the file, find the property "CommonViewFields". It should look like this:
<property name="CommonViewFields" type="string" />
Change it to include the URL field:
<property name="CommonViewFields" type="string">URL,text</property>
Save and import the file into the page (you can delete the web part you had on the page):
Click the "Page" menu and select add webparts - import
Browse to the file you just saved, and click Upload. drag and drop the web part to the page.
So now the web part "knows" about the URL column. Now we have to "teach" it to show it properly.
Open the site in SharePoint Designer. Under the root, find the "Style Library" folder, and then the "XSL Style Sheets" folder. right click the "ItemStyle.xsl" file and choose "checkout":
After checking it out, open it. We are looking for the "NoImage" template. It should start with a line like this:
<xsl:template name="NoImage" match="Row[@Style='NoImage']" mode="itemstyle">
Copy the entire template (from the "<xsl:template" to "</xsl:template>") and paste it underneath. This is where we will create our own style - just for links.
In the new section, change the code using the following rules (full code to follow):
- Rename "No Image" to "LinkList"
- Change the "href" attribute to point to the URL column, the text before the comma.
- Change the link text to point to the URL column, the text after the comma
Here is the code:
Save the file and publish it.
Warning - if you paste it wrong or delete some character by mistake, all your content query web parts may stop working in the site collection. If that happens, either check out the file and use the undo function (if it's still in memory) or right click the file and use the version history to roll back. You may also want to download the file as a backup.
Go back to the web part page with the uploaded webpart that has a referance to the URL field (the one we imported earlier), and open the web part properties. This may take a while, but under "Presentation" - "Styles" - "Item Style" you should have the "LinkList" style to select. Select it and click ok.
The web part should now display the titles of the list items, and the link should point at the link target. Also, the description of the link should appear as a tool tip when you hover over the link:
note - my site has a modified style sheet, so bullets look like ">". You'r links should appear like regular bullets.