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.

What controls the incrementing of view_count_one, view_count_two, view_count_three, view_count_four?

July 14, 2008 3:39pm

Subscribe [6]
  • #1 / Jul 14, 2008 3:39pm

    Is there a switch in EE that controls if these columns are incremented or not?

    I’m looking at the exp_weblog_titles table, and these columns are all 0 for items I KNOW have been viewed.  I’m starting to wonder if we’ve implemented a system where we aren’t using the proper URL to trigger a “view”.

    For instance…this URL shows all of the blog posts:
    http://www.covlife.org/blog/

    I wouldn’t expect a view count to be incremented.  BUT if you click a particular post, like this one:
    http://www.covlife.org/blog/welcome

    I would expect that entry to have its count increased by one.  But it is not.

    The way we bring up a particular section entry is using this template code:
    [template filename=blog]
    {exp:weblog:entries weblog="BLOG_NAME" orderby="date" sort="desc"}
    ...
    {/exp:weblog:entries}

    we are relying on the “welcome” in the URL to match the url_title field—the whole dynamic=“on” thing which is on by default.  This is working great for us…this individual post comes up, but it is definitely NOT triggering the view counts to increase.

    Is there a “right” way to have a URL to an invidiaul section entry?

    Any help would be greatly appreciated.

    Thanks.

    -Aaron

  • #2 / Jul 14, 2008 3:43pm

    Lisa Wess

    20502 posts

    You’re missing the track_views parameter… that is what controls if a single entry page records a hit.

  • #3 / Jul 14, 2008 3:54pm

    WOW…how did I miss that one?  😊

    Quick question: is there anyway in the main control panel to view the # of view counts?

    I see it shows the # of comments…it would be cool to show the # of views when you Edit | search for a particular section.

    -Aaron

  • #4 / Jul 14, 2008 4:06pm

    Lisa Wess

    20502 posts

    Not currently, unless you want to custom code an extension.

    What I personally do?  I show it on all my pages, but restricted to only me seeing it (using my member_id, or the superadmin group).

    Just an option. =)

  • #5 / Jul 14, 2008 4:10pm

    I very much would like to build a custom code extension, but we’re talking about changing the “Edit Section entries” table results—that’s seems pretty low level/core EE code.

    Can I do that as an official extension?  Or do I just hack up some core PHP code?

    -Aaron

  • #6 / Jul 14, 2008 4:14pm

    Ingmar

    29245 posts

    Aaron, this is precisely the reason for extensions in the first place, so you don’t have to hack PHP code. You might want to look into the edit_entries_* hooks.

  • #7 / Jul 14, 2008 4:22pm

    That is WAY cool!  All I need to do is tap into ‘edit_entries_modify_tableheader’—add a new column header “Hits” ... and then tap into ‘edit_entries_modify_tablerow’—add the column data…I may have to write code to query out the values in the columns:  view_count_one, view_count_two, view_count_three, view_count_four

    But all in all, this should work great!  I am surprised and amazed at EE every day I use it!

    So…how do I actually use these two hooks?  I see it mentions the file: cp.publish.php

    Do I edit that file directly?

    -Aaron

  • #8 / Jul 14, 2008 4:24pm

    Lisa Wess

    20502 posts

    Hi, Aaron,

    No, as Ingmar said, hooks exist to avoid you hacking.  You can look at the code there to see how it works; but I’d also recommend looking at an existing, first-party extension to see how extensions work and tap into the hooks.  The development documentation should also help. =)

  • #9 / Jul 14, 2008 4:33pm

    Ok, so where do I turn on these extension hooks and edit them if I’m not touching the cp.publish.php file?

    I checked in Admin | Utilities | Extension Manager…..I see “No Extensions Exist”.  It looks like Extensions are at least enabled.

    Do I have to install the “Hooks” extension and then manage it from Extension Manager?

    I feel like I’m missing something.

    -Aaron

  • #10 / Jul 14, 2008 4:36pm

    Lisa Wess

    20502 posts

    The extension hooks exist already and are there for you to tap into. The Extension Manager is for managing existing extensions (that make use of those hooks, of course)

  • #11 / Jul 14, 2008 4:39pm

    Ingmar

    29245 posts

    No, you have to write the whole extension yourself, as it were. This extension would “take over” from EE at some point, process the data itself and hand it back to EE, overriding some of the core code with your own. You’ll really have to read up on extension development if you want to use it effectively, though.

  • #12 / Jul 14, 2008 4:40pm

    Ok, how do I tap into one?

    This page:
    http://expressionengine.com/developers/extension_hooks/edit_entries_modify_tableheader/

    says:
    Hook File Location: cp.publish.php


    So to tap into it…do I open the cp.publish.php file, look for the ‘edit_entries_modify_tablerow’ section and edit it?

    -Aaron

  • #13 / Jul 14, 2008 4:42pm

    Ingmar

    29245 posts

    No, you don’t. Please follow the link I provided and read up on the issue. Also, Lisa gave you very good advice there, take an existing extension and see how it does what it does. Thanks.

  • #14 / Jul 14, 2008 4:44pm

    I think I understand now…I have to author an extension—the list of hooks are my entry points, but I have to write an extension that will tap into those existing hooks.

    I was reading it as “existing hooks” == there exists a place where I can write custom PHP code that would be called upon and interpretted if something was set (and I couldn’t figure out where to set it).

    But really these hooks are the starting points for extensions to be built.

    I got it now [if that is all correct]  😊

    -Aaron

  • #15 / Jul 14, 2008 5:32pm

    SWEET!  I just wrote my first extension, and it works GREAT!

    In the search results table on the “Edit Section Entries” page…there is now a “Hits” column and it shows the # of hits that entry has received.

    Of course there are 4 different columns, but I’m only querying the first.  (I suppose you could query all of them and then display any non-zero values like “4 / 12 / 9”)

    Anyway, thanks for your help once again.  I guess I’ll post this “Entry Hits” extension up on the Add-On Library page.

    -Aaron

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

ExpressionEngine News!

#eecms, #events, #releases