We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38547
    • 98 Posts
    I am using hits to on my Articles blog to show the 5 most visited paged, using the following:

    On sidebar of site pages
    [[!Hits?
    &parents=`28`
    &limit=`10`
    &outputSeparator=`,`
    &chunk=`hitID`
    &toPlaceholder=`hit`]]
    
    [[!getResources?
    &parents=`-1`
    &resources=`[[+hit]]`
    &sortby=`FIELD(modResource.id,[[+hit]] )`
    &sortdir=`ASC`
    &tpl=`pageTitle`
    ]]


    The chunk called hitID referenced in that call contains this
    [[+hit_key]]


    the pageTitle tpl contains this
     <li class="title"><a href="[[~[[+id]]]]">[[+pagetitle]]</a></li>


    and on all the pages I want to have counted I have added this
    [[!Hits? &punch=`[[*id]]`]]


    What I cant workout is how to show how many hits each page has received, I planned in my pageTitle template to show something like pagetitle (hits)
    I am sure this has been asked on here before but a search of the forum did not reveal anything about hits.
    Can anyone point me in the right direction.

    Cheers

    Ian
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      It looks like you need to use the [[+hit_count]] placeholder somewhere in there.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 38547
        • 98 Posts
        Quote from: sottwell at Feb 09, 2014, 01:19 PM
        It looks like you need to use the [[+hit_count]] placeholder somewhere in there.
        Thats what I thought so I added [[+hit_count]] at then end on my pageTitle tpl but it outputs nothing at all, maybe I need do to something with it first so it knows to count the page views.
          • 3749
          • 24,544 Posts
          Since &toPlaceholder is set to `hit` I think you'll need this to show the results:

          [[!+hit]]
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 38547
            • 98 Posts
            Quote from: BobRay at Feb 09, 2014, 05:03 PM
            Since &toPlaceholder is set to `hit` I think you'll need this to show the results:

            [[!+hit]]
            OK got ya yes that is starting to work it outputs at the end of every line the resource ID's 38,61,72,57,44,41,55,70,58,43

            Looks like I need some kind of snippet to sort the output.

            I am thinking I should use http://rtfm.modx.com/extras/revo/hitspage instead, I have not tried that yet as I saw that hits is a recent version so I presumed better but maybe not for me.

            Thanks for advice