ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

View count query not counting accurately

May 18, 2011 12:49am

Subscribe [2]
  • #1 / May 18, 2011 12:49am

    DigitalDesigns

    94 posts

    We have a Most Popular section on our site that displays the most viewed entries and there respective view counts. We have gotten it to display counts, but some are rising at numbers that exorbitant, other are lower than the actual view count, while some incidentally match the actual view counts.
    Here is our code, any ideas as to what we need to correct?
    Thanks!

    {exp:channel:entries limit="5"}
    <a href="http://{comment_url_title_auto_path}">_{exp:trunchtml chars="29" inline=" ..."}{title}{/exp:trunchtml}_</a>
    
    {/exp:channel:entries}      
     {exp:query 
    sql="select entry_id, view_count_one as cnt, url_title, title 
    from exp_channel_titles 
    where view_count_one > 0
    order by view_count_one desc limit 5"
    }Views:{cnt}
    {/exp:query}
  • #2 / May 18, 2011 2:03am

    Cheif

    626 posts

    So you have confirmed that the true DB values for viewcount are incorrect or they are incorrect using that above ?

    Why wouldn’t you simplify the code and use orderby=“view_count_one” in your exp tag ?

    Also, what version are you running ?

  • #3 / May 18, 2011 11:27am

    Sue Crocker

    26054 posts

    Thanks for the assist, Cheif.

    Cheif’s right, you could do this via a orderby=“view_count_one”, but the hits being done should be the same. If you suspect the values are wrong, you could zero out the values and start over. Something I’d suggest doing once a month or so.

  • #4 / Jun 02, 2011 7:12pm

    DigitalDesigns

    94 posts

    Thanks for the help!
    Here is how we got it to work:


    {exp:channel:entries limit="5" orderby="view_count_one"}
      _   {exp:trunchtml chars="35" inline=" ..."}{title}{/exp:trunchtml}_  
      Views:{view_count_one}
      {/exp:channel:entries}

    Much simpler than what we attempted - thanks!

  • #5 / Jun 02, 2011 8:17pm

    Sue Crocker

    26054 posts

    Glad you found a workaround.. If anything else comes up, please do let us know in a new thread..

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases