Gossamer Forum
Quote Reply
number links
Hi,

I would like to install a module allowing to place the number of click on the links in this way:100.000

I tested with this option but this one gives me: 100000

Ci below the global.

sub {
my $total = shift;
my ($total) = $DB->table('Links')->select(['SUM(Hits)'])->fetchrow_array; return 0 unless defined $total;
1 while s/^([-+]?\d+)(\d{3})/$1.$2/;
return $total;
}
Quote Reply
Re: [michelb] number links In reply to
So you want to be able to add ,'s or .'s at 3 digit intervals, to make iut easier to read/understand?

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [michelb] number links In reply to
Hi,

Yes, it may not work correctly. It will be bad if the link number is 100000000 or something like that.
Did you use the sprintf function to format this number?

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [A.J.] number links In reply to
hi,

What I would like is to make the number of times that the links were clicked in the form of 100.000 (3 digit); what I have for the moment which is displayed is: 100000.

But whit this global, he doesn't work

Thank's
Quote Reply
Re: [michelb] number links In reply to
Have a look at http://www.perldoc.com/...-localeconv-function

That might help (for the regex).

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [michelb] number links In reply to
Hi, you seem to have it a little mixed up. You are using $total = shift but then making $total the value of whatever number is returned from the database query.

More importantly though (and the reason for it not working) is the regex is trying to use $_ when it needs $total


Try:

Code:
sub {
my $total = $DB->table('Links')->select('SUM(Hits)')->fetchrow;
return 0 unless defined $total;
1 while $total =~ s/^([-+]?\d+)(\d{3})/$1.$2/;
return $total;
}

That will turn something like 1000000 into 1.000.000

Last edited by:

Paul: Apr 3, 2002, 4:44 AM
Quote Reply
Re: [Paul] number links In reply to
I have tried this global, and he work fine

Thank's for your help
Quote Reply
Re: [Paul] number links In reply to
I have added two additional fields (for click tracking), Field1 and Field2.

How to count total hits including those two (Total sum of Hits, Field1 and Field2)

So, I need Total SUM of Hits+Field1+Field2

Thanks in advance!
Quote Reply
Re: [Payooo] number links In reply to
<%Hits + Field1 + Field2%>

Unsure

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] number links In reply to
In Reply To:
<%Hits + Field1 + Field2%>


Thanks Andy, but, that one doesn't work.

You gave me the idea.



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

Works fine! Is it OK to use it?

How to do that for each link?
Quote Reply
Re: [Payooo] number links In reply to
Mmm...not sure. How about adding my $ID_look = shift; after the sub { part, and then a WHERE clause to only select where the ID equals $ID_look ? Then just place it in link.html.

Hope that helps Smile

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] number links In reply to
Thanks Andy, but I don't have a clue how to do that. Blush

Any help is welcome.