Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alexadar 17 posts 37 karma points
    Nov 19, 2011 @ 20:17
    Alexadar
    0

    List of most visited pages

    Hi!

    Im using your package.

    How can i retreive a list of most visited pages by XLST macro?

    Also, can i retreive list of most visited pages by type? f.e. i want to list most popular products

    Thank you

  • Robert Foster 459 posts 1820 karma points MVP 3x admin c-trib
    Nov 20, 2011 @ 08:33
    Robert Foster
    0

    Hi Alexadar,

    I've just uploaded a new version which should make this easier for you as it now automatically registers the library as an XSLT extension.  Go download it and then try the following sample XSLT:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
      <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library"
      xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon"
      xmlns:ViewCount="urn:ViewCount"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon ViewCount">

      <xsl:output method="xml" omit-xml-declaration="yes"/>

      <xsl:param name="currentPage"/>

      <xsl:template match="/">
        <ul>
          <xsl:for-each select="$currentPage//* [@isDoc ]">
            <xsl:sort select="ViewCount:GetViews(number(@id))//@count" order="descending"/>
            <xsl:variable name="counter" select="ViewCount:GetViews(number(@id))" />

            <li>
              Node: <xsl:value-of select="$counter//@nodeId" /><br />
              Count: <xsl:value-of select="$counter//@count" /><br />
              Last Viewed: <xsl:value-of select="$counter//@lastViewed" /><br />
              Category: <xsl:value-of select="$counter//@category" /><br />
              hide Counter: <xsl:value-of select="$counter//@hideCounter" /><br />
              enable History: <xsl:value-of select="$counter//@enableHistory" />
            </li>
          </xsl:for-each>
        </ul>
      </xsl:template>

    </xsl:stylesheet>

    Note that the ordering may not be quite what you expect if you try for the entire tree; if you filter for all products under a common parent for example, you may have better results.

    I'll be posting a blog entry about the functions available in the library in the next day or so when I have more time.  But for now, try these:

    • ViewCount:GetViews(int nodeId, string category)
      ViewCount:GetViews(int nodeId, string category, bool increment)
      ViewCount:Increment(int nodeId, string category)
      ViewCount:Reset(int nodeId, string category)
      (int) ViewCount:GetViewCount(int nodeId, string category, bool increment)

    Increment increments the view count for a node only without returning any results; Reset resets the viewcount back to 0.

    GetViewCount just returns the actual count by itself.

    - Rob

  • Alexadar 17 posts 37 karma points
    Nov 21, 2011 @ 17:50
    Alexadar
    0

    It's working great!

    thanks!

  • Jignesh 31 posts 51 karma points
    Jan 18, 2012 @ 15:22
    Jignesh
    0

    How to use ViewCount. I am not able to getting properly. I am not using Razor.

    Can you please give me steps to work with this?

    Thanks alot..

  • Robert Foster 459 posts 1820 karma points MVP 3x admin c-trib
    Jan 18, 2012 @ 23:32
    Robert Foster
    0

    Hi Jignesh,

    Perhaps you could tell us a bit about what you have done so far and what you would like to achieve...  Have you tried the XSLT script above?  Have you configured the Data Type and added it to your content pages?

  • Jignesh 31 posts 51 karma points
    Jan 19, 2012 @ 06:31
    Jignesh
    0
Please Sign in or register to post replies

Write your reply to:

Draft