Gossamer Forum
Quote Reply
total hits
I would like to add something like "Total Hits" to my site

I saw this post...from Alex - GT....which appears to be the kind of thing that I would like to do.

Is this easy & straight forward to implement?

Any advice - comments much appreciated.

Thanks - ColinT

Hi,

Add a global:

total_hits =>

--------------------------------------------------------------------------------
Code
--------------------------------------------------------------------------------

sub { my ($total) = $DB->table('Links')->select(['SUM(Hits)'])->fetchrow_array; return $total; }

--------------------------------------------------------------------------------


and then use <%total_hits%> in your template.

Cheers,

Alex
--
Gossamer Threads Inc.
Colin Thompson
Quote Reply
Re: [colintho] total hits In reply to
Quote:
Is this easy & straight forward to implement?

Very...just do as Alex suggested =)
Quote Reply
Re: [Paul] total hits In reply to
Paul - Thanks

I meant "Total Hits" from my site.... - I guess this is the same

Is this where I put the code?

globals.txt This is your globals file. It contains a list of tags that will be available on every template. You should not edit it by hand, but rather use the built in editor in the admin.

Regards

ColinT
Colin Thompson
Quote Reply
Re: [colintho] total hits In reply to
Yes, go to Build > Template Globals. The text field is for the global name, and the textarea is for the global code.
Quote Reply
Re: [Paul] total hits In reply to
Paul

is there a template that I can put the tag

<%total_hits%>

into as a "test" befor putting it onto my homepage?

thanks

ColinT
Colin Thompson
Quote Reply
Re: [colintho] total hits In reply to
Releif - it works - tried it on my homepage

Many Thanks - Paul

regards

ColinT
Colin Thompson