none
How can I customise the CQWP to display posts from a blog?

    질문

  • Hi,

    I want to customise the CQWP so that it displays posts from a blog. The information I want to display would be Title; Date, Body Text and Date Published.

    I’ve found some great posts showing how to customise the CQWP to display information from an article page. I’ve done this before to good effect. Heather Solomons blog on this is very good: http://www.heathersolomon.com/blog/articles/CustomItemStyle.aspx

    Unfortunately I have found very little on how to customise the CQWP to display Blog posts. Has anyone done this?

    Any guidance would be appreciated. NB: I’m not so techy so clear guidelines would be appreciated :)

    Thanks for any help offered.

    Regards,
    Marc


    • 편집됨 majrmarcee 2012년 3월 9일 금요일 오후 12:48
    2012년 3월 9일 금요일 오후 12:48

답변

모든 응답

  • Hi,

    Please check out the following blog posts: http://collab.rdacorp.com/2010/06/using-content-query-web-part-to.html and http://arabic2000.com/blog/index.php/archives/293


    Kind regards,
    Margriet Bruggeman

    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com


    • 편집됨 Margriet BruggemanMVP 2012년 3월 9일 금요일 오후 1:25
    • 답변으로 표시됨 majrmarcee 2012년 3월 12일 월요일 오전 8:29
    • 답변으로 표시 취소됨 majrmarcee 2012년 3월 12일 월요일 오전 9:03
    2012년 3월 9일 금요일 오후 1:24
  • Edit: below is for sharepoint blog

    Hi Marc, 

    You are on the right track with Heather's article, displaying blog posts is pretty much the same, the only thing you need is to add Date and Date Published to you ItemStyle.xsl file.

    Add the following namespace attribute to the root xsl:stylesheet element (line 6) to get the dates

    xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime

    In your item template you now can set variables for your date and display it in any format you want

    	<xsl:variable name="dateTime" select="ddwrt:FormatDate(string(@Date), 1033, 3)" />
    	<xsl:variable name="dateTimeCondensed" select="ddwrt:FormatDate(string(@Date), 1033, 2)" />
    	<xsl:variable name="date"  select="substring-before(substring-after($dateTime, ', '), ', ')" />
    	<xsl:variable name="month" select="substring-before($date, ' ')" />
    	<xsl:variable name="day"   select="substring-after($date, ' ')" />
    	<xsl:variable name="time"  select="substring-after($dateTimeCondensed, ' ')" />
    @Date will refer to the column with the date, use the same set up to pull in your Date Published values, just modify your var names i.e. dateTimePubished and replace the string with @DatePublished

    so now you can pull in the date in any way you want: <xsl:value-of select"$dateTime"/> or just a date <xsl:value-of select="$date"/>

    Title and Body will use the same set up as in Heather's article. 

    To set up the display for non-sp blogs you will need to use XML webpart, link it to a rss feed and use XSL Editor to add your display, check the fields that are generated i.e something simple for wordpress blog:

    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" indent="yes"/>
    <xsl:param name="TITLE"/>
    <xsl:template match="rss">
      <div style="background:#fff; padding:0; font-size:100%;">
          <xsl:for-each select="channel/item">
    		<xsl:if test="position() &lt;= 5">
    		<p><a href="{link}" target="_new" style="margin-bottom:10px;margin-left:4px;margin-top:6px;display: block;"><xsl:value-of select="title"/></a><xsl:value-of select="pubDate"/><br/>
    <xsl:value-of select="description" disable-output-escaping="yes"/>
    	</p>   
         
    		</xsl:if>
            
          </xsl:for-each>
      </div>
    </xsl:template>
    </xsl:stylesheet>
    

    hope this helps somewhat, 

    Evgenia.



    • 편집됨 Evgenia Fisher 2012년 3월 9일 금요일 오후 3:23 wordpress stuff added
    2012년 3월 9일 금요일 오후 2:56
  • Thank you both for pointing me in the right direct. I ended up using the information on the RDA blog as it was easy to understand. The code is all there for you too. http://collab.rdacorp.com/2010/06/using-content-query-web-part-to.html A great resource for anyone wanting to do this.

    • 답변으로 표시됨 majrmarcee 2012년 3월 12일 월요일 오전 8:31
    2012년 3월 12일 월요일 오전 8:31
  • Actually you don't need to export/import CQWP in Sharepoint 2010 to specify additional fields.

    Add your template to ItemStyles.xsl, and when you select your template in Presentation > Item style> you will have an option to add your additional fields.

    2012년 3월 12일 월요일 오후 12:35
  • Hello Evgenia, 

    I have followed the same blog posts and direction on how to use the CQWP to pull blog posts summary list... My problem is this. When i click on the read mor elink or title to read the full blog post it takes me to the actual blog site. What would i do to stay on my publishing site and just pull the blog post it self possibly in another webpart on on the same page? So for example. In my ItemStyle.xsl where i created my custom style. there is this: 

      <a href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}"> 
                                        <xsl:value-of select="$DisplayTitle"/> 
                                    </a> 

    i am assuming i need to replace $SafeLinkUrl with something else to get it to pull the post?

    I have been stuck on this for weeks. Can someone help?

    2012년 4월 5일 목요일 오후 9:41