Hit Counter - Multiple-Entry Page
If you absolutely positively must have a “hit” counter on a multiple-entry page.
Adding a hit counter to a single entry page in EE; one with an entry_id number in the URL is pretty straightforward, just add a parameter like
track_views="one"
to your weblog tag and then add
{view_count_one}
in between your weblog tag pair.
But if you need to count page visits to a multiple-entry page; one with a category number in the URL; a “C” number, this isn’t as simple.
The following is a non-elegant non-hack workaround that works when you only need a counter on one multiple-entry page.
Create a new template called “hit_counter” and add a weblog tag like this one to it:
{exp:weblog:entries weblog="your_weblog_name" entry_id="your_entry_id_number" dynamic="off" track_views="one" disable="categories|category_fields|custom_fields|member_data|pagination|trackbacks"}
Page Visits: {view_count_one}
{/exp:weblog:entries}
You’ll need to update these two parameters for your site:
weblog="your_weblog_name"
entry_id="your_entry_id_number"
Choose some entry for the entry_id that’s always open and current. If it closes or expires, your counter will likely stop working.
Now, in your template that displays the content of the multiple-entry page where you need the counter to snow up, add this:
{if segment_3 == ‘C10’}{embed=template_group_name/hit_counter}{/if}
You’ll need to update the “C##” with the category number of the page where you want the counter to display and update the template_group_name with the name of your template group.
Update the template and go check it out on your site. You should see something like:
Page Visits: 1
That’s it. A non-elegant non-hack workaround for a one page hit counter that works on a multiple-entry page in EE.
Category:Tricks Category:Hit Counter
