Welcome Guest, Not a member yet? Register   Sign In
Count visits
#1

[eluser]yannyannyann[/eluser]
I would like to know what is the best way to implement a tool to see the most visited pages.

I have Medias (stored into a database) with a field "visits" (INT)

How do I increment this value ? have to check IP of visitor or stuff like that ?
(I never did that before)


Sorry I am new to code igniter and it's a bot complex to see what classes / helpers exist and what doesn't...

thanks in advance



Yann
#2

[eluser]jedd[/eluser]
[quote author="yannyannyann" date="1236298349"]I would like to know what is the best way to implement a tool to see the most visited pages.

I have Medias (stored into a database) with a field "visits" (INT)

How do I increment this value ? have to check IP of visitor or stuff like that ?
[/quote]

If you want to count the number of page loads, then you don't need to. If you want to count the number of unique page loads (ie. from distinct computers) then you will need to. But doing this will be expensive, so think about what data you really want to collect.

(If you want to just collect page hits - you can get away with an int field attached to each page. If you want to collect page hits that are unique, you're going to need to keep a table full of IP addresses, correlated to each page, and an int to count each pairing.)

I suggest you'd have a line in your constructor for each controller (or extend the CI controller) and have a call out to a model with the information you require (this might be segment's 1-3 at a guess). The model method will do the necessary magic to update your DB, of course.

Quote:Sorry I am new to code igniter and it's a bot complex to see what classes / helpers exist and what doesn't...

From the CI User Manual page (you can use your local copy - it'll jump out to google) you can use the search box up the top. In this case it came up blank on anything vaguely appropriate.

In these forums you can use the search box up the top .. and I found these two links (of how much value, only you can say Smile

[url="http://ellislab.com/forums/viewthread/66923/"]http://ellislab.com/forums/viewthread/66923/[/url]
[url="http://ellislab.com/forums/viewthread/60257/"]http://ellislab.com/forums/viewthread/60257/[/url]
#3

[eluser]kgill[/eluser]
The "best way" is not to do it, this is what your web server's log files are for, run them through just about any analyzer (analog, awstats, etc) and you'll get the information you're after as well as plenty of other details. However, if for some reason your host won't let you see your log files and you need to roll your own stats collector then the advice above is a good start.
#4

[eluser]yannyannyann[/eluser]
Thanks,

I think I won't deal with IPs then.

Basically I need to find a solution because I have to display a menu, like :
Sort by : Most viewed




Theme © iAndrew 2016 - Forum software by © MyBB