show page views in each webpage
Permalink Browser Info Environment
Hi, just installed, everything works fine, just a question.
We want to show, in footer of each website page, the page view counter.
May i can do that, with a simple php row like that (i used for showing last update of a page)
print $c->getCollectionDateLastModified()
Thanks in advance for your reply
We want to show, in footer of each website page, the page view counter.
May i can do that, with a simple php row like that (i used for showing last update of a page)
print $c->getCollectionDateLastModified()
Thanks in advance for your reply
Type: | Ticket |
---|---|
Status: | Resolved |
Thanks for support.
Now i can view page views in each webpage integrating in the template output of query:
"SELECT hits,CID,SUM(hits) as PageViews FROM `whaleStatsPages` WHERE cID = ".$c->getCollectionID()
Now i can view page views in each webpage integrating in the template output of query:
"SELECT hits,CID,SUM(hits) as PageViews FROM `whaleStatsPages` WHERE cID = ".$c->getCollectionID()
Exactly.
Cheers for sharing.
Cheers for sharing.
Happy to helping someone else !
Here the complete script I used in my template (not elegant, but functional):
Here the complete script I used in my template (not elegant, but functional):
<?php // Create connection $conn = mysqli_connect("localhost", "DBUSER", "DBPWD", "DBNAME"); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } // Sort cID of current page $IdPagina = $c->getCollectionID(); $sql = "SELECT hits,CID,SUM(hits) as PageViews FROM `whaleStatsPages` WHERE cID = '".$IdPagina."' "; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { echo "Page Views = ".$row["PageViews"]; }
Viewing 15 lines of 17 lines. View entire code block.
There is no built-in API for doing such a thing, but the data is there in the database. You can query the `whaleStatsPages` table manually.