views:

236

answers:

2

I have a content query web part showing 3 events for todays date on our Intranet homepage. However, when a user deletes an event from a recurring series, SP changes the title of that event to "Deleted: [original title]". My content query web part still shows these and I don't see a way to filter them out.

For my list views I get around it with a field and a formula in that field of the following. =IF(ISNUMBER(FIND("Deleted:",Title)),"Yes","No").
However, that field isn't available to me within the CQWP filter drop-down.

how does one prevent these deleted occurrences from showing in a CQWP?

UPDATE: This is a publishing page BTW.

+1  A: 

Have you tried the DataFormWebPart (DFWP) before? It is basically the most basic of databound webparts, but strangely the most customizable as well.

To try it out, open SharePoint designer and create a dummy aspx page to work on / play around with. Then open the datasources pane and find the list you want to use. then click on that list and select "view data". Drag the appropriate fields onto the aspx page. You now have a (very) basic grid displaying your data.

The cool thing is though, all layout is xsl driven, so completely customizable. You can even make the xsl reusable by switching to source view and cut and paste the xs,l into a separate xsl file. To then use this file instead of the inline xsl, after moving the inline xsl, change the DFWP property xsl (that contained the inline xsl) from

<xsl><!-- .... this is where the moved inline xsl used to be... --></xsl>

to

<xsllink>/server relative url to xsl file</xsllink>

The only remaining problem is that the DFWP's datasource is now bound a single list. To do roll-ups cross site collection (if you have say multiple event lists you want to include), you need to change the DFWP's SPDataSource's select query and datasourcemode. How to do that is explained here.

Now to address your actual question: (after my blatant plug of the underappreciated DFWP :-D) The DFWP's SPDataSource basically uses either an SPQuery or an SPSiteDataQuery (depending on the datasourcemode) to retrieve the data, and you can do way more filtering wise. Either in the CAML query itself or by just filter out the unneeded rows using something like the following:

<xsl:if test="not(contains(@Title, 'Deleted:'))">
  <xsl:apply-templates />
</xsl:if>
Colin
While this is a good idea, it wont work on a publishing page as those cant be edited in SP Designer.
Marc
Why not? You can still have a webpartzone on a publishing page, so just create your webpart in spdesigner, then from SPD's file menu export the webpart (to a file or the webpart gallery) Now you can just add the webpart to your page through the sharepoint UI.
Colin
Ahhh, sure, that would work. I'll keep that in mind.
Marc
+1  A: 

While you can perform the filter via XSLT, it may be preferable to do so in the CAML query itself. This article from Microsoft, How to: Customize the Content Query Web Part by using Custom Properties, shows how the CAML Where clause is constructed (and may be modified). Good luck!

Jason Weber
I forgot about this. I did it elsewhere on the site almost a year ago. ;-) Thanks.
Marc