Hit Counter

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Barrowboy
Forum Members
Forum Members
Posts: 223
Joined: Mon Dec 16, 2013 4:09 pm

Hit Counter

Post by Barrowboy »

Hi
I am using the hit counter to display a list of all pages using, this command on a selected page. {HitCounter action=popular} The page is called 'Page Stats' and is set to not show in menu but is selected from a link.
I also have this {HitCounter} in my template (not sure if this is needed.) I am hiding the individual page display with some CSS.

The pages display correctly in my page, but is it possible to select certain pages not to display.

Thanks
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Hit Counter

Post by velden »

{HitCounter} will count the hits for the specific page. So, if you don't want a page to show in the popular results make sure that page doesn't use the HitCounter tag.

I guess you could use some conditional logic for that in the template.

(untested)

Code: Select all

{if $page_alias != 'contact' || $page_alias != 'disclaimer'}{HitCounter assign=foo}{/if}
Note the assign parameter to prevent output of the {HitCounter} tag to your page (no need to hide with css)

You can make it more flexible by using another check. E.g. use one of the extra attributes in page options.

Code: Select all

{page_attr key='extra1' assign='extra1'}
{if trim($extra1) != 'SkipHitCounter'}{HitCounter assign=foo}{/if}
Then in the Extra 1 field of the pages you don't want to be counted type 'SkipHitCounter' (without the quotes)
Gingertom
New Member
New Member
Posts: 7
Joined: Fri Jul 10, 2015 7:12 pm

Re: Hit Counter

Post by Gingertom »

Unfortunately the bit off code to hide the page doesn't appear to work.
I am using {if $page_alias != 'page-stats' || $page_alias != 'disclaimer'}{HitCounter assign=foo}{/if}

Page-Stats is the page I am trying to hide.

The code is in the template 'Popular' in the foreach loop, tried other places but still no good.

Any further suggestions.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Hit Counter

Post by velden »

That code should be in the page template.
Gingertom
New Member
New Member
Posts: 7
Joined: Fri Jul 10, 2015 7:12 pm

Re: Hit Counter

Post by Gingertom »

The code in it's present form crashes site when added to the page template. It just doesn't like it.

Could you give more info.

{if $page_alias != 'page-stats' || $page_alias != 'disclaimer'}{HitCounter assign=foo}
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Hit Counter

Post by velden »

I think it's better if you give some more info: like the error message when the site 'crashes', system info etc.

btw. in the code of your latest post you're missing the cloing {/if}
Gingertom
New Member
New Member
Posts: 7
Joined: Fri Jul 10, 2015 7:12 pm

Re: Hit Counter

Post by Gingertom »

Sorry missed the closing </if>
Thanks for pointing that out. I'm a little bit new to all this but learning fast.

Site is now ok but the page in question is still visible.

The code is in the page template.

But does it matter were?

i.e. should it go in the head section.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Hit Counter

Post by velden »

Obviously you need to reset the previous results first.
Gingertom
New Member
New Member
Posts: 7
Joined: Fri Jul 10, 2015 7:12 pm

Re: Hit Counter

Post by Gingertom »

Reset the counter but still no luck the page still appears in the list.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Hit Counter

Post by velden »

check the logic of the if-statement

Code: Select all

{if $page_alias != 'page-stats' || $page_alias != 'disclaimer'}<h1>PAGE ALIAS IS NOT page-stats NOR disclaimer</h1><h2>$page_alias = {$page_alias}</h2>{/if}
Gingertom
New Member
New Member
Posts: 7
Joined: Fri Jul 10, 2015 7:12 pm

Re: Hit Counter

Post by Gingertom »

Hi Velden

I have checked over and over. This is what is in the template.

{if $page_alias != 'page-stats' || $page_alias != 'disclaimer'}{HitCounter assign=foo}{/if}

Which is what I think you suggested at first.

The page alias was copied and pasted from the page alias column. So I am sure its correct.
Post Reply

Return to “Modules/Add-Ons”