HiddenNetwork.com Banner
Showing posts with label Content Query Web Part. Show all posts
Showing posts with label Content Query Web Part. Show all posts

Wednesday, June 27, 2007

Adding table headers and/or footers to a Content Query Web Part Layout

Just found this article by Mike Gehard which shows a good step by step of making a content query web part look like a grid - with column headers and all.
Mike is even using the same ddwrt trick as I am for formatting dates, and I now see that his blog seems to be dedicated to the content query web part!


I recommend you go to Mike's blog and read all about it. The method he is taking is chaning the "ContentQueryMain.xsl" file to pass the lastrow as a parameter to the "CallItemTemplate", and then in "CallItemTemplate" he passes the lastrow to the apply templates itemstyle.
In the "Itemstyle.xsl" file you add html variables for the header and the footer, and use them before the first row and after the last row.
I will try to contact Mike and ask for permission to reprint his article here for redundancy.

Mike - if you are reading this, how about you join the Enhanced Content Query Web Part project?

Tuesday, June 26, 2007

Using DDWRT in xslt-based web parts

What is DDWRT?
well, its a script that microsoft packaged for it's xslt dataviews, that gives them more xslt power.
I needed to use the ddwrt functions in my content query web part, but I guess that the following approach will work in the search web parts as well.

Why do we need it?
I needed it to format the date I was getting back from the content query. The format I was getting back was ugly to the user (2007-06-27 15:52:00) and I wanted to format it, but I didn't want to write my own function.

So how to use it?
you need to add to your xslt the following namespace where the namespaces are declared (at the top of the xsl file, in the "xsl:stylesheet" tag):
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"

Then you can use the ddwrt's functions. For example, to format the date I used the following:
<xsl:value-of disable-output-escaping="no" select="ddwrt:FormatDate(string(@Modified), 3081, 5)" />
Note that in the FormatDate function I used 2 hard coded values - 3081 which is the LCID for Australia (so the date will be formatted to Australian date format) and 5 which specifies the what do I want to display - date, time, date and time ect. I have no idea what values give what, but I do know that 5 gives me the date and the time.

Thursday, June 21, 2007

Call for beta testers! Enhanced Content Query Web Part

This is to call beta testers. I want to kick the ECQWP project to beta2, which requires beta testers to start testing and reporting on Beta 1 (well, 1.3 actually) .
You don't need to write to me or anything - just get a free codeplex account, and use it in the ECQWP project site to add issues (bugs) to be fixed, or ask for enhancements.
Please try to be VERY clear on the problem - preferably with a step by step of what I need to do to get the error you are describing.

While I am at it, if you are a good SharePoint developer and you think you have the ability to solve the bugs, let me know, and I will add you to the project as a developer, and assign bugs for you to fix.
Please note - this is not a practice run. I do not have time to mentor beginners, so don't use this as a free training exercise. Sorry.

Wednesday, June 20, 2007

Adding custom fields to the Enhanced Content Quey Web Part (Beta 1.2)

I just got around to adding another important feature to the Enhanced Content Query Web Part and I uploaded it to codeplex.
I am sure you read my articles, or articles by other MVPS like Heather about showing custom columns in the content query webpart. This requires (as Heather's article shows) that you export the web part to a file, manually modify the file to add the fields you want, and import it back.
This annoyed me enough to add a property to my ECQWP that will allow you to add those fields without having to export-import.

In this version (1.2) you have two new properties in the propeties pane - Data Fields and Common View Fields. I have yet to find out how Data Fields are used, so you don't need to use that property - it is enough that you set the Common View Fields.
I will refer you to Heather's article to find out the format that the value of this property should be written in - how to get the field's internal name, and how to get the field's type. Just a quick reminder though - the value in that field is a pipe seperated value of fields, where each field is a coma seperated pair of field (internal) name and field type. For example, a text field with internal name "Comments" will be added like so:
Comments,Text
A choice field with internal name "Client_x0020_Name" will be added like so:
Client_x0020_Name,Choice
and if we want to add both of the above fields, it will look like so:
Comments,Text|Client_x0020_Name,Choice


As always, get the web part, installation instructions and source code from codeplex. Just be sure to download the most recent version.

Tuesday, June 19, 2007

Enhanced Content Query Web Part upgraded to Beta 1.1

I am happy to announce that the Enhanced Content Query Web Part project has progressed to Beta 1.1, with some very important fixes to major bugs.

The web part now correctly prints out the item ID, has context menus for folders (not just documents) and supports displaying icons for documents.

Be sure to read the documentation (installation instructions) and use the new XSLT that is provided there. The old XSLT will not solve any of the bugs I fixed.

Tuesday, June 05, 2007

Enhanced Content Query Web Part goes Beta 1!

Hey Everyone!
This is to let you know that I released beta 1 of the Enhanced Content Query Web Part Project. Make sure you read the installation documentation to the end, because that is where you will find the sample XSLT that will cause the menus to appear.

Anyone want to volunteer to draw me a logo? Contact me!

Monday, June 04, 2007

Coming Soon! Content Query Web Part with Context Menus

Well, I promised you something that will knock your socks off, so hold on!
I have started a new open source project for an Enhanced Content Query Web Part that will have the enhancement (in the first stage) of Context Menus.
(note - the project is not yet published - I need to figure out why my laptop suddenly refuses to connect to codeplex, and I will release the beta)
Content Query Web Part for MOSS with Context Menus

Additional features that will come with this release include the ability to add the default toolbar (new, updload, actions, settings) to the web part when it is connected to a specific library or list (not in aggregation mode)
Content Query Web Part with Toolbar
Some things will not work as you'd expect (if you select a view using the view selector it will redirect you to the view, not change the current web part) but it is a very useful addition to the web part's abilities!

I intend for this project to grow to be a true replacement of the content query web part, and that is why I am calling this project "Enhanced Content Query Web Part".
I hope others who have done work around enhancing the built-in web part like Meron Friedman (Content Query Web Part with marquee) and Steven Van de Craen (extended Content Query Web Part with item limit per group *link seems to be broken?*) will join me as developers on this project, and integrate their code with mine.

I am also looking for advanced developers to help me get my current code stabilized. If you want to help - contact me.

Wednesday, May 23, 2007

Content Query Web Part xsl for showing the xml

I keep forgetting this, and I think I had to figure it out from scratch at least 4 times allready, so I may as well blog it.
The thing is - last time I figured it out I wanted to blog about it, and then saw that someone beat me to it - Heather Solomon already wrote about it in her blog, and I seem to remember someone else wrote a similar script.
The thing that throws me off every time is realizing that the XML that the content query web part builds for each item has the values in the attributes. So what you need to do is write xslt code to display the attributes.

Heather's article says exactly how to modify the files, so if you need that kind of help, go there now. Below is the code that I am using (slightly modified):

<xsl:template name="ShowXML" match="Row[@Style='ShowXML']" mode="itemstyle">
    <xsl:for-each select="@*">
        </br>
        Name: <xsl:value-of select="name()" /> Value:<xsl:value-of select="." />
    </xsl:for-each>
</xsl:template>

I have just managed to do something really cool with the web part, but I have to refine it a bit before I publish it. I promise this will knock your socks off!