Page 1 of 1
Hit Counter
Posted: Wed Jul 08, 2015 2:01 pm
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
Re: Hit Counter
Posted: Wed Jul 08, 2015 10:33 pm
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)
Re: Hit Counter
Posted: Sat Jul 11, 2015 8:10 am
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.
Re: Hit Counter
Posted: Sun Jul 12, 2015 1:16 am
by velden
That code should be in the page template.
Re: Hit Counter
Posted: Sun Jul 12, 2015 7:27 am
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}
Re: Hit Counter
Posted: Sun Jul 12, 2015 3:19 pm
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}
Re: Hit Counter
Posted: Mon Jul 13, 2015 7:09 am
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.
Re: Hit Counter
Posted: Mon Jul 13, 2015 8:06 pm
by velden
Obviously you need to reset the previous results first.
Re: Hit Counter
Posted: Tue Jul 14, 2015 3:51 pm
by Gingertom
Reset the counter but still no luck the page still appears in the list.
Re: Hit Counter
Posted: Tue Jul 14, 2015 3:58 pm
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}
Re: Hit Counter
Posted: Tue Jul 14, 2015 6:21 pm
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.