How to create a Blog post Rollup Webpart (CQWP)
There are two main steps in this process: customize the ItemStyle and the CQWP. You can find the reference on adding properties to the CQWP at this MSDN article.
So, we export the CQWP and edit the line that has CommonViewFields to become <property name=”CommonViewFields” type=”string”>Body, Note</property>
Here, Body is the post body text and Note is its type (yes, it’s not RichHtml as you may think), but how do we know? You check the schema file at \14
\TEMPLATE\FEATURES\DiscussionsList\Discuss
Now that we have the field available in the CQWP, we edit the item style. The ItemStyle.xsl file lives in the Style Library in your site collection (only there, one style library per site collection) inside the folder XSL Style Sheets (that’s easy to figure out). You download the file and open it in a text or xml editor. Here, we will copy the default style and paste it under the original (starts with <xsl:template name=”Default” match=”*” mode=”itemstyle”> and ends with </xsl:template> – around 67 lines). Of course, we need to name our style – I replaced the first line by <xsl:template name=”AKTemplate” match=”Row[@Style='AKTemplate']” mode=”itemstyle”> You will notice we have a few blocks of xsl variables and I added my new one under the last one (Display Title)
<xsl:variable name=”bodyContent”>
<xsl:call-template name=”removeMarkup”>
<xsl:with-param name=”string” select=”@Body”/>
</xsl:call-template>
</xsl:variable>
We will get back to the removeMarkup soon (I used the same one by Heather).
The code starting with <div class=”item”> is where we show the data, so I added
<div class=”description”>
<xsl:value-of select=”substring($bodyContent,1,75)”/> … (<a href=”{$SafeLinkUrl}” mce_href=”{$SafeLinkUrl}” target=”_blank” title=”{@LinkToolTip}”>More</a>) </div>
</div>
just before the last </div> in that block (close to the end of the template). Here, I am taking the first 75 characters of the clean text and added a link to see the full post.
Finally, I added the template that strips out html tags right after the closing tag of my custom template (</xsl:template>). The removeMarkup template is available from Heather’s post toward the end and is clearly marked.
Save the xsl file and re-upload to the styles library (xsl style sheets folder). You need to publish a major version for this to work (not only check it in).
Now, you add a web part to your page based on the exported and adjusted one (under the web part groups, locate the Upload web part then select from imported web parts). Configure your CQWP and select your new item style (do not add Body; in the Description field!). If you did not have typos, you should see something similar to the above screen shot. If your itemstyle is not correct, your CQWP will not show and will give error (add ?contents=1 to the url and delete it, then roll back to the previous version of the itemstyle until you fix the custom one). See more on Heather’s blog on how to see available fields and find types etc.
20 comments:
How to display author's Name, Published date and Category
This looks like exactly what I need and, not being a developer, I was following along well until the part starting with "The code starting with <div class=”item”. Looks like you may have left out parts. Can you provide the whole code so that I might follow it better? Thanks so much for contributing! -Dave
Wonderful information, your website gives the best and the most interesting information. Regards, SharePoint 2013 Administration Training in Hyderabad
Excellent information, I had come to know about your website from my friend, and let me tell you, your site gives the best and the most interesting information. Regards, SharePoint 2013 Developer Training in Hyderabad
Information was good, I like your post.
Looking forward for more on this topic.
Sharepoint online tutorials, sharepoint videos on youtube
Wonderful post however I was wondering if you could write a little more on this topic? I’d be very thankful if you could elaborate a little bit further. Thank you!
SharePoint training Institute
Great article ...Thanks for your great information, the contents are quiet interesting. I will be waiting for your next post.
SharePoint Online Trainings
I have read you blog..very useful information for SharePoint training.Thank you for sharing you article.SharePoint Training in Chennai
Nice article i was really impressed by seeing this article, it was very interesting and it is very useful for Learners..
SharePoint Course in Chennai | SharePoint Course
Really its a good post for those who want to learn about CQWP. I'm genuinely impressed the way you've explained it to readers. This is the post I was looking for and I would like to thank you for the whole informative stuff. Carry on the great work.
Top 2017 Dental Websites, Custom dental web development for dentists.
I appreciate that you took a simple, how to article by explaining the process step by step and how to create blog post. can you help me on Dental Implants in Hyderabad
hii thank you for sharing
SharePoint Online Training Bangalore
Great Site, The Course were so simple and easy to understand.
Sharepoint Training in Hyderabad
Spot on with this write-up, I truly think this website wants much more consideration. I’ll probably be once more to read much more, thanks for that info. bovada casino
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
sharepoint Training in Electronic City
Thanks for a very interesting blog, I would like to share Best Dental Clinic in Manikonda ,Hyderabad that uses latest technology for all the dental needs.
Thanks for sharing this wonderful content.its very useful to us.
I gained many unknown information, the way you have clearly explained is really fantastic.
oracle training in chennai
oracle training institute in chennai
oracle training in bangalore
oracle training in hyderabad
oracle training
hadoop training in chennai
hadoop training in bangalore
Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing.
Salesforce Training in Chennai
Salesforce Online Training in Chennai
Salesforce Training in Bangalore
Salesforce Training in Hyderabad
Salesforce training in ameerpet
Salesforce Training in Pune
Salesforce Online Training
Salesforce Training
Very Nice Blog…Thanks for sharing this information with us. Here am sharing some information about training institute.
best devops online training in hyderabad
A Dedicated Server is a physical server that's assigned to a single organization.
Post a Comment