Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm using the content query webpart to query a blog list and it is working well for the most part, the issue i'm having has to do with the categories that the blog has been associated with when a blog has more than one category the PostCategory field contains data that looks like this:

1;#Category1;#2;#Category2

Which contains both the id and the name of the category which I can use to build a link to the blog category filter page. When a given blog entry is associated with one category it the PostCategory field just renders out like this:

Category1

My question is how can I get the id of the category where there is only one? I know this has to be possible because SharePoint gets it with the stock blog template. I have combed through the blog.xsl file and have come up empty, any ideas on this one?

share|improve this question

1 Answer 1

Did you define the Category field in the CommonViewFields property of the web part to pass as "Lookup" type? (a la: http://msdn.microsoft.com/en-us/library/ms497457.aspx)

Edit: snippet from my .webpart file as per the comments:

 <property name="CommonViewFields" type="string">PostCategory</property>
share|improve this answer
    
Yes I did. I'm getting 1;#Category1;#2;#Category2 when the blog entry has more than one associated category so it's pulling the right data. The problem is when there is only one there is no ID in the string. –  James May 11 '11 at 16:49
    
Odd - I've not seen this... and you're doing just a bog standard xsl:value-of yeah? –  James Love May 11 '11 at 16:59
    
Do you see an id in the string when there is just a single category association? –  James May 11 '11 at 17:12
    
Yep - though for me I had a teamsite at top of site collection level, created a blog underneath it, fired up the Publishing Infrastructure to get me the CQWP, added it, modded ItemStyle to spit out @PostCategory, exported a CQWP, wired it up to Posts list, added PostCategory to CommonViewFields, and it renders the number of the category as well as the name, even when only 1 is selected. –  James Love May 11 '11 at 17:46
    
Tried same thing you did, fresh team site with a fresh blog and the same result as before, could you update your post with what you have in your working exported webpart for => DataMappings, DataMappingViewFields, CommonViewFields? –  James May 11 '11 at 19:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.