Rod's profileRod StaggPhotosBlogListsMore Tools Help

Blog


    October 11

    Implementing Content Ratings for Sharepoint via site template Part 1

    contentrating
    I had a request to create the typical content rating system you see on the web but for Sharepoint 2007-the catch? I needed to deploy as a site template that could be deployed easily by site collection owners.
     
    What did I come up with you ask? 
     
    First, it's amazing what the new aggregate data sources in Sharepoint 2007 and x-path can do:)
     
    You can use the new linked datasouces to access data in other lists, web services, and even SQL sources.
     
    Then using X-path, XSL, javascript, and customizing the dataview web-part you have some options for doing interesting things in site templates that you might not have thought about before or would immediately consider server-side code a requirement.  
     



    The Approach
    Displaying the ratings from within your list/document library. 
     
    The basic approach is to tie your custom list to a second list that stores the rating using a common id.  You can use javascript for this.
    Then on your custom list use an x-path query to get a handle to the rows you want and then render the star rating appropriately.   
     
    Warning: I haven't provided all the steps here and there are a few to getting the different parts of the solution connected and working together-this example covers only the bare essentials of displaying the ratings from within your list/document library but should get you off to a good start.
     
    Coming in Part 2: The custom XSL for displaying data on the view ratings page.
    Coming in Part 3: Pre-populating the ratings fields and filtering the results set by adding parameters to the aggregate datasource select query. 
    Coming in Part 4: How to configure a datasource to be easily deployed as part of a site template deployed within a site collection on a different server.
     
    Displaying the aggregated rating for a specific list item or document:
    Once I linked to the list where I stored all my ratings it was a matter of building an x-path query to aggregate data from the ratings list in order to display my star ratings in the custom list:
     
    From the row item template on a custom list contained with a DVWP in XSLT format:
     
    <xsl:template name="dvt_1.rowview">
      <xsl:param name="ParentPath" />
      <xsl:param name="SrcPos" />
      <xsl:variable name="dvt_1ParentRow" select="current()" />
      <xsl:variable name="FilteredRatedQuestions" select="../../../Call_Question_Ratings/Rows/Row[@QuestionID=$dvt_1ParentRow/@ID]" />
     
    Once I had a handle to a proper rowset then I could perform whatever calculations I deem necessary to display the appropriate star ratings:
     
    In my scenario a five star rating based on a simple average sufficed and used the images already available in the layouts directory.
     
    <xsl:choose>
              <xsl:when test="../../../Call_Question_Ratings/Rows/Row/@QuestionID=$dvt_1ParentRow/@ID">
              
                 <xsl:variable name="dvt_1RowRating" select="format-number(sum($FilteredRatedQuestions/@Rating)div (@_x0023_Rated), &quot;###0.0;-###0.0&quot;)"/>
                <xsl:if test="$dvt_1RowRating &gt;= '2' and $dvt_1RowRating  &lt; '3'">
                  <img src="\_layouts\images\addtofavorites.gif" border="0" align="absmiddle"/>
                  <img src="\_layouts\images\addtofavorites.gif" border="0" align="absmiddle"/>
                 </xsl:if>
                 
                 <xsl:if test="$dvt_1RowRating &gt;= '3' and $dvt_1RowRating  &lt; '4'">
                  <img src="\_layouts\images\addtofavorites.gif" border="0" align="absmiddle"/>
                  <img src="\_layouts\images\addtofavorites.gif" border="0" align="absmiddle"/>
                  <img src="\_layouts\images\addtofavorites.gif" border="0" align="absmiddle"/>
                 </xsl:if>
                
                 <xsl:if test="$dvt_1RowRating &gt;= '4' and $dvt_1RowRating  &lt; '5'">
                  <img src="\_layouts\images\addtofavorites.gif" border="0" align="absmiddle"/>
                  <img src="\_layouts\images\addtofavorites.gif" border="0" align="absmiddle"/>
                  <img src="\_layouts\images\addtofavorites.gif" border="0" align="absmiddle"/>
                  <img src="\_layouts\images\addtofavorites.gif" border="0" align="absmiddle"/>
                 </xsl:if>
                
                 <xsl:if test="$dvt_1RowRating &gt;= '5' and $dvt_1RowRating  &lt; '6'">
                  <img src="\_layouts\images\addtofavorites.gif" border="0" align="absmiddle"/>
                  <img src="\_layouts\images\addtofavorites.gif" border="0" align="absmiddle"/>
                  <img src="\_layouts\images\addtofavorites.gif" border="0" align="absmiddle"/>
                  <img src="\_layouts\images\addtofavorites.gif" border="0" align="absmiddle"/>
                  <img src="\_layouts\images\addtofavorites.gif" border="0" align="absmiddle"/>
                 </xsl:if> 
               
                        
             </xsl:when>
             <xsl:otherwise>
                 <img src="\_layouts\images\addtofavorites.gif" border="0"/>
                </xsl:otherwise>
             </xsl:choose>
     
    Cheers!

    Comments (4)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.
    Rod Stagg has turned off comments on this page.
    No namewrote:
    http://www.batterylaptoppower.com/laptop-ac-adapter/ibm/ibm-16V-3.5A-56w-5.5mm-2.5mm.php 02K6553 02K655 ibm 16V 3.5A 56w 5.5mm*2.5mm adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/ibm/ibm-20V-3.25A-65w-7.9mm-5.5mm-DC-with-pin-inside.php 92P1153 92P1154 ibm 20V 3.25A 65w 7.9mm*5.5mm DC with pin inside adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/ibm/ibm-20V-4.5A-90w-7.9mm-5.5mm-grey-DC-with-pin-inside.php PA-1900-171 ibm 20V 4.5A 90w 7.9mm*5.5mm grey DC with pin inside adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/liteon/liteon-19V-3.42A-65w-5.5mm-2.5mm-white.php liteon 19V 3.42A 65w 5.5mm*2.5mm white adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/liteon/liteon-19V-3.16A-60w-5.5mm-2.5mm.php liteon 19V 3.16A 60w 5.5mm*2.5mm adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/liteon/liteon-19V-3.95A-75w-5.5mm-2.5mm.php PA-1750-01 liteon 19V 3.95A 75w 5.5mm*2.5mm adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/liteon/liteon-19V-4.74A-90w-5.5mm-2.5mm.php PA-1900-15 liteon 19V 4.74A 90w 5.5mm*2.5mm adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/liteon/liteon-19V-6.3A-120w-5.5mm-2.5mm.php PA-1121-08 liteon 19V 6.3A 120w 5.5mm*2.5mm adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/liteon/liteon-19V-6.3A-120w-4pin-round.php liteon 19V 6.3A 120w 4 pin round adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/liteon/liteon-20V-6A-120w-5.5mm-2.5mm.php liteon 20V 6A 120w 5.5mm*2.5mm adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/liteon/liteon-19V-4.74A-90w-5.5mm-1.7mm.php PA-1900-04 liteon 19V 4.74A 90w 5.5mm*1.7mm adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/liteon/liteon-19V-6.32A-120w-4-pin.php liteon 19V 6.32A 120w 4 pin adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/liteon/liteon-20V-6A-120w-4-pin.php liteon 20V 6A 120w 4 pin adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/samsung/samsung-19V-3.16A-60w-5.5mm-3.4mm-pin-inside.php SPA-P30 AD-6019 samsung 19V 3.16A 60w 5.5mm*3.4mm pin inside adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/samsung/samsung-19V-4.74A-90w-5.5mm-3.0mm.php PCGA-AC19V3 samsung 19V 4.74A 90w 5.5mm*3.0mm adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/sony/sony-19.5V-4.7A-90w-6.5mm-4.4mm.php PCGA-AC19V sony 19.5V 4.7A 90w 6.5mm*4.4mm adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/sony/sony-16V-4A-65w-6.5mm-4.4mm.php sony 16V 4A 65w 6.5mm*4.4mm adapter PCGA-AC16V4
    http://www.batterylaptoppower.com/laptop-ac-adapter/sony/sony-19.5V-3A-58w-6.5mm-4.4mm.php sony 19.5V 3A 58w 6.5mm*4.4mm adapter PCGA-ACX1 PCGA-AC19V1
    http://www.batterylaptoppower.com/laptop-ac-adapter/sony/sony-19.5V-4.1A-80w-6.5mm-4.4mm.php sony 19.5V 4.1A 80w 6.5mm*4.4mm adapter PCGA-AC19V3
    http://www.batterylaptoppower.com/laptop-ac-adapter/toshiba/toshiba-15V-3A-45w-6.3mm-3.0mm.php toshiba 15V 3A 45w 6.3mm*3.0mm adapter PA2450U PA3241U-1ACA
    http://www.batterylaptoppower.com/laptop-ac-adapter/toshiba/toshiba-15V-4A-60w-6.3mm-3.0mm.php toshiba 15V 4A 60w 6.3mm*3.0mm adapter PA3092U-1AC PA2444U
    http://www.batterylaptoppower.com/laptop-ac-adapter/toshiba/toshiba-15V-5A-75w-6.3mm-3.0mm.php PA3283U-1ACA toshiba 15V 5A 75w 6.3mm*3.0mm adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/toshiba/toshiba-15V-6A-90w-6.3mm-3.0mm.php toshiba 15V 6A 90w 6.3mm*3.0mm adapter PA2501U PA2521U PA3201U-1ACA
    http://www.batterylaptoppower.com/laptop-ac-adapter/toshiba/toshiba-15V-8A-120w-special-4-hole.php toshiba 15V 8A 120w special 4 hole adapter PA3237U-1ACA PA3237U
    http://www.batterylaptoppower.com/laptop-ac-adapter/toshiba/toshiba-19V-3.42A-65w-5.5mm-2.5mm.php toshiba 19V 3.42A 65w 5.5mm*2.5mm adapter PA3467U-1ACA PA3396U-1ACA
    http://www.batterylaptoppower.com/laptop-ac-adapter/toshiba/toshiba-19V-3.16A-60w-5.5mm-2.5mm.php toshiba 19V 3.16A 60w 5.5mm*2.5mm adapter PA3097U-1ACA
    http://www.batterylaptoppower.com/laptop-ac-adapter/toshiba/toshiba-19V-4.74A-90w-5.5mm-2.5mm.php toshiba 19V 4.74A 90w 5.5mm*2.5mm adapter PA-1750-04
    http://www.batterylaptoppower.com/laptop-ac-adapter/toshiba/toshiba-19V-6.3A-120w-6.3mm-3.0mm.php toshiba 19V 6.3A 120w 6.3mm*3.0mm adapter PA3290U-1ACA
    http://www.batterylaptoppower.com/laptop-ac-adapter/universal/universal-12-20V-90W-universal.php universal 12-20V 90W universal adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/universal/universal-12-20V-120W-universal.php universal 12-20V 120W universal adapter laptop
    http://www.batterylaptoppower.com/laptop-ac-adapter/universal/universal-12-20V-70W-universal.php universal 12-20V 70W universal adapter laptop
    http://www.batterylaptoppower.com/universalbattery.htm universal battery for laptop

    http://www.batterylaptoppower.com/kohjinsha/SR.htm kohjinsha SR battery
    http://www.batterylaptoppower.com/kohjinsha/SH.htm kohjinsha SH battery
    http://www.batterylaptoppower.com/kohjinsha/SX.htm kohjinsha SX battery
    http://www.batterylaptoppower.com/kohjinsha/sc.htm kohjinsha sc battery
    http://www.batterylaptoppower.com/kohjinsha/SY.htm kohjinsha SY battery
    June 22
    wo wowrote:

    http://www.batteryfast.co.uk/gateway/m320.php GATEWAY BATTERY 6500922 m320 m325 4000mx laptop battery ,
    http://www.batteryfast.co.uk/gateway/m680.php Gateway M360 M460 M680 8-Cell Notebook Battery 6500949 laptop battery ,
    http://www.batteryfast.co.uk/gateway/s62066l.php GATEWAY BATTERY s62066l m320 m325 4000mx laptop battery ,
    http://www.batteryfast.co.uk/gateway/squ-412.php Gateway 11.1v 4400mah M360 M460 M680 battery laptop battery ,
    http://www.batteryfast.co.uk/gateway/4ur18650f-2-qc-ea1.php 4ur18650f-2-qc-ea1,6500632,6500665 laptop battery ,
    http://www.batteryfast.co.uk/gateway/6500358.php battery for solo 9300 6500358 GT-6300L laptop battery ,
    http://www.batteryfast.co.uk/gateway/bat0016.php gateway bat0016 Motion M1200 M1300 laptop battery ,
    http://www.batteryfast.co.uk/gateway/btp-68b3.php Battery for Gateway Solo M500 M505 Medion MD2900 MD6179 laptop battery ,
    http://www.batteryfast.co.uk/hp/320912-001.php HP Compaq Battery for NC8200 nc8230 7400 laptop battery ,
    http://www.batteryfast.co.uk/hp/336962-001-002-battery.php Battery fits HP Pavilion zt3000 zt3010US 337607-001 laptop battery ,
    http://www.batteryfast.co.uk/hp/364602-001.php New Battery For Compaq NX6120 NC6100 NC6120 NX6100 NC6200 laptop battery ,
    http://www.batteryfast.co.uk/hp/dv6000.php New OEM HP HSTNN-DB42 DV2000 DV6000 V3000 V6000 laptop battery ,
    http://www.batteryfast.co.uk/hp/dv9000.php New OEM HP HSTNN-LB33 dv9000 DV9000 dv9600 laptop battery ,
    http://www.batteryfast.co.uk/hp/hp510.php laptop battery for hp 510 530 HSTNN-FB40 laptop battery ,
    http://www.batteryfast.co.uk/hp/hp520.php NEW Battery for HP 500 HSTNN-FB39 434045-661 laptop battery ,
    http://www.batteryfast.co.uk/hp/hstnn-c16c.php Battery fits HP Pavilion DV8000 DV8100 DV8200 laptop battery ,
    http://www.batteryfast.co.uk/hp/hstnn-db02.php Battery For HP HSTNN-IB04 346970-001 HSTNN-DB02 DP399A laptop battery ,
    http://www.batteryfast.co.uk/hp/hstnn-db17.php New Battery for HP M2000 Series DV1000 DV4000 laptop battery ,
    http://www.batteryfast.co.uk/hp/nc2400-battery.php New Compaq 2510p NC2400 Laptop Extended Battery EH768AA laptop battery ,
    http://www.batteryfast.co.uk/hp/nc4000.php HP NC4010 DD880A NC4000 laptop battery ,
    http://www.batteryfast.co.uk/hp/nc6000.php battery for Compaq/HP NX5000 NC6000 NC8000 DG105A 4.4A laptop battery ,
    http://www.batteryfast.co.uk/sony/pcga-bp2sa-002-battery.php grey Battery For Sony PCGA-BP2S PCGA-BP2SA VAIO PCG-SR17 NEW laptop battery ,
    http://www.batteryfast.co.uk/sony/pcga-bp2sa-battery.php Battery For Sony PCGA-BP2S PCGA-BP2SA VAIO PCG-SR17 NEW black laptop battery ,
    http://www.batteryfast.co.uk/sony/pcga-bp2t.php battery fits sony PCGA-BP2T PCGA-BP3T PCG-TR1/B PCG-TR2 laptop battery ,
    http://www.batteryfast.co.uk/sony/pcga-bp2v.php laptop Battery for Sony PCGA-BP2V laptop battery ,
    http://www.batteryfast.co.uk/sony/pcg-gr100.php Original SONY pcga-bp2e vgp-bp2ea pcg-gr100 Battery laptop battery ,
    http://www.batteryfast.co.uk/sony/vgp-bps2a.php LAPTOP BATTERY SONY VAIO VGP-BPS2 VGP-BPS2B VGP-BPS2A black laptop battery ,
    http://www.batteryfast.co.uk/sony/vgp-bps2a-002-battery.php 7.2ah LAPTOP BATTERY SONY VAIO VGP-BPS2 VGP-BPS2B VGP-BPS2A black laptop battery ,
    http://www.batteryfast.co.uk/toshiba/pa3209u-1brs.php Battery for Toshiba Satellite 1100 1110 PA3209U-1BRS laptop battery ,
    http://www.batteryfast.co.uk/toshiba/pa3399u.php battery fits TOSHIBA PA3399U-1BAS PA3399U-1BRS 6600mAH laptop battery ,
    http://www.batteryfast.co.uk/toshiba/pa3399u-1bas.php Battery for Toshiba PA3399U-1BRS PA3399U-2BAS 1BAS laptop battery ,
    http://www.batteryfast.co.uk/toshiba/pa3356u-1brs.php Toshiba PA3356U-3BAS PA3356U-3BRS PA3456U-1BRS Battery laptop battery ,
    http://www.batteryfast.co.uk/toshiba/pa3356u-1brs-002-battery.php 8.8ah Battery TOSHIBA PA3356U-1BAS PA3356U-1BRS PA3356U-2BRS laptop battery ,
    http://www.batteryfast.co.uk/toshiba/pa3420u.php toshiba pa3420u-1brs l10 l15 l20 laptop battery ,
    http://www.batteryfast.co.uk/toshiba/pa3421u-1brs.php Battery for Toshiba M30X M35X M40X PA3395U-1BRS PA3421U laptop battery ,
    http://www.batteryfast.co.uk/toshiba/pa3431u-1brs.php TOSHIBA SATELLITE M65 BATTERY PA3431U-BRS PABAS068 laptop battery ,
    http://www.batteryfast.co.uk/toshiba/pa3451u.php TOSHIBA PA3451U-1BRS PABAS067 laptop battery ,
    http://www.batteryfast.co.uk/toshiba/pa3465u.php Genuine TOSHIBA PA3465U-1BRS Laptop Battery PABAS069 laptop battery ,
    http://www.batteryfast.co.uk/toshiba/pa3536u-1brs-002-battery.php 6.6ah New PA3536U Battery for Toshiba Satellite P200 P205 laptop battery ,
    http://www.batteryfast.co.uk/toshiba/pa3536u-1brs-battery.php New PA3536U Battery for Toshiba Satellite P200 P205 laptop battery ,
    http://www.batteryfast.co.uk/toshiba/pa3534u-1brs-battery.php NEW Genuine Toshiba Battery Satellite PA3534U-1BRS A205 laptop battery ,
    http://www.batteryfast.co.uk/laptop-ac-adapter/acer/acer-19V-3.16A-60w-5.5mm-1.5mm.php acer 19V 3.16A 60w 5.5mm*1.7mm adapter laptop battery ,
    http://www.batteryfast.co.uk/laptop-ac-adapter/acer/acer-19V-3.16A-60w-5.5mm-2.5mm.php PA-1500-02 PA-1600-02 acer 19V 3.16A 60w 5.5mm*2.5mm laptop adapter laptop battery ,
    http://www.batteryfast.co.uk/laptop-ac-adapter/acer/acer-19V-3.42A-65w-5.5mm-2.5mm-big-head.php PA-1700-02 PA-1650-02 acer 19V 3.42A 65w 5.5mm*2.5mm big head adapter laptop battery ,
    http://www.batteryfast.co.uk/laptop-ac-adapter/acer/acer-19V-3.42A-65w-5.5mm-1.5mm-small-head.php acer 19V 3.42A 65w 5.5mm*1.7mm small head adapter SADP-65KB SADP-65DB laptop battery ,

    June 19
    Rod Staggwrote:
    ileana,
     
    check out the recent posts section on my blog's homepage:
    Re-Publish Implementing Content Ratings for Sharepoint via SP Designer-Part II Step by Step
    Content Rating Part III-adding a customized sort expression
    Sharepoint Content Rating Site Template Update (this is an .stp site template that can be uploaded and used on MOSS 2007 site collection using the collaboration portal template. 
    Nov. 9
    Picture of Anonymous
    ileana wrote:
    It seems to be exactly what I need!
    It's very interesting, but where are the part 2,3 and 4?
    Nov. 7

    Trackbacks (3)

    The trackback URL for this entry is:
    http://rodstagg.spaces.live.com/blog/cns!11725DEB07615960!176.trak
    Weblogs that reference this entry