Welcome, Guest. Please login or register.
Did you miss your activation email?
May 23, 2012, 07:08:08 PM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
155439 Posts in 21702 Topics by 7732 Members
Latest Member: Smacki
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: New Snippet: Mini Counter - Most popular pages  (Read 8535 times)
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2294



WWW
« on: August 19, 2008, 11:09:33 PM »

I created a small snippet today and called it "Mini Counter".

It does what it says. It is a simple page counter.
News/Bakery//Catalog/GoCart/Gallery subpages are counted seperately.


Installation:

Install the zipfile as a normal module through the WB backend.
Add the php code to your template index.php.


Using the snippet:

Code:
Default:  <?php MiniCounter(); ?>    
 
Optional parameters: <?php MiniCounter$show_counter$hits_text$today_text$closing_text ); ?>

  $show_counter = Echo the counter result (default := 1, 0 no output)
  $hits_text = The text in front of the total hits counter. (default := "Pagehits: ", if set to "" no total counter is displayed)
  $today_text = The text in front of the today hits counter. (default := " (Today: ", if set to "" no daily counter is displayed)
  $closing_text = Optional text to close the result of the snippet. (default := ")", if set to "" no closing is displayed)

Customised Example: <?php MiniCounter("Hits: " " [Today: " "]" ?>

No Output: <?php MiniCounter(0); ?>

There is no nice overview output (yet), just the counter in the page.
I invite all to build a backend page to look at stats using the data.

October 6 - Version 0.22

This version has a second snippet added.
<?php Popular_Pages(); ?>
This will create a links block with the 5 pages (or more) with the most page views.

Optional parameters: <?php Popular_Pages( $count, $title, $show_menu_title, $show_totals ); ?>

  $count = The amount of pages listed by the snippet.
  $title = The heading of the block. It is written in a <div class="popularpages"><h2><h3> </h3></h2></div>
      -- The listing itself is written in <div class="popularlist"><ul><li>........</li></ul></div>
  $show_menu_title = If set to 0 (default = 1) the page title is used for the link. Not the menu_title.
  $show_totals = if set to 1 a tooltip will be added to the link with the total pageviews for that page.


Ruud
« Last Edit: October 06, 2008, 08:48:54 PM by Ruud » Logged

Professional WebsiteBaker Solutions
vyni

Offline Offline

Posts: 566


« Reply #1 on: August 20, 2008, 03:01:12 AM »

Hi Ruud,

I didn´t know - but this is exactly what I needed.
Just a small line in the footer. Thank You.

Regards from Himberg
Logged

PS: Falls jemand eine Idee hat was zu tun ist und mir das erklären könnt - geh bitte davon aus dass ich ahnungslos bin, was php und so betrifft. Ich kann grad was lesen, kopieren und einfügen,  ungefähr verfolgen und glauben.
aldus

Offline Offline

Posts: 1238


« Reply #2 on: August 20, 2008, 09:41:15 AM »

Hello Ruud

A nice one smiley

Only minor changes inside the include.php and index.php file

  • Add commentblock within some comments ... mostly taken from the posting of Ruud.
  • Add "if ( ($page == 0) OR ($show_counter == 0) ) return;" to get rid of the unnessesary "if" at the end of the function
  • Add a "counter_total = 0" to get a valid value in every kind of circumstances.
  • Minor code-cleaning at the end of the function.
  • Minor code-cleaning in subfunction "subItem()".
  • Add "../" inside the "index.php" to get rid of the "index.php is calling index.php is calling index.php" situation.


Regards
Aldus

Logged
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2294



WWW
« Reply #3 on: August 20, 2008, 09:56:46 AM »

Hi Aldus,

Some day I will post a module/snippet where you don't need to polish up anything  grin

One modification I don't agree on.
If $show_counter = 0 we still want the page to be counting, just not output any results.
The idea is that the backend some day will get some functionality to look at the page hits.

I know this can also be done by using 3 empty params, but just a yes/no seemd more logical to me.
Adding the snippet in your template and tell it not to do anything doesn't make much sense to me.

The $page=0 test is to prevent counting hits on search results and possible other dynamic pages that should not be counted.

Cheers,

Ruud
Logged

Professional WebsiteBaker Solutions
aldus

Offline Offline

Posts: 1238


« Reply #4 on: August 20, 2008, 10:01:12 AM »

Hello Ruud

Ok - i over-read the "show_counter" sence ... rolleyes (a little bit too fast ...)

Regards
Aldus
Logged
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2294



WWW
« Reply #5 on: October 06, 2008, 09:31:19 AM »

Hi All,

I updated the MiniCounter snippet with an extra function.

<?php Popular_Pages(); ?>

This will display a list of links (menu style) of the most viewed pages.
See the first post and the readme.txt in the .zip for more info.

Ruud
Logged

Professional WebsiteBaker Solutions
erpe

Offline Offline

Posts: 2077


WWW
« Reply #6 on: October 06, 2008, 04:38:41 PM »

Hi Ruud

that does not work for me.
Anyone who had this work?

rgds

erpe
Logged

erpe

Offline Offline

Posts: 2077


WWW
« Reply #7 on: October 06, 2008, 05:02:25 PM »

Got it work  grin

Testpage

Thanks for that.

rgds

erpe
Logged

vyni

Offline Offline

Posts: 566


« Reply #8 on: October 06, 2008, 05:05:27 PM »

Hi Ruud,

as usual - nice thing.

So the Visitor is alway´s informed....

There is just a little mistake in the read-me. You explain:
Quote
 $title = The heading of the block. It is written in a <div class="popularpages"><h2> </h2></div>

But in fact the code generates h3.

regards from Himberg
Logged

PS: Falls jemand eine Idee hat was zu tun ist und mir das erklären könnt - geh bitte davon aus dass ich ahnungslos bin, was php und so betrifft. Ich kann grad was lesen, kopieren und einfügen,  ungefähr verfolgen und glauben.
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2294



WWW
« Reply #9 on: October 06, 2008, 08:43:40 PM »

But in fact the code generates h3.

Ooops, must have been a Freudian mistake.
I always wanted to use h2's, but for some reason I end up using h3's.  grin

Ruud


Logged

Professional WebsiteBaker Solutions
daydreamer

Offline Offline

Posts: 252


« Reply #10 on: May 17, 2009, 10:04:13 AM »

Is there a way to count unique visits only , Also not count search engines

Thanks
Logged
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2294



WWW
« Reply #11 on: May 17, 2009, 11:04:41 AM »

No,

There is a reason this snippet is called minicounter wink

Have a look at this, this is a full counter with nice statistics.
Here it is explained how to use it.

Ruud
Logged

Professional WebsiteBaker Solutions
solbu

Offline Offline

Posts: 22


« Reply #12 on: April 04, 2010, 07:59:06 PM »

Is there a way to reset the counter?
Logged

My posts are licensed under a Creative Commons license
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2294



WWW
« Reply #13 on: April 04, 2010, 08:47:42 PM »

Just uninstall and install a fresh one.

That should do the trick
Logged

Professional WebsiteBaker Solutions
flaens

Offline Offline

Posts: 6


« Reply #14 on: December 16, 2011, 08:21:16 AM »

hi,
is it possible to show the counter just on one page?
Logged
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2294



WWW
« Reply #15 on: December 16, 2011, 09:55:07 AM »

Sure,

Just find the page_id of the page you want it to show and use:

Code:
<?php 
if (PAGE_ID == 123) {
 
MiniCounter("Hits: " " [Today: " "]" );
}
?>
Logged

Professional WebsiteBaker Solutions
flaens

Offline Offline

Posts: 6


« Reply #16 on: December 16, 2011, 10:35:05 AM »

Sure,

Just find the page_id of the page you want it to show and use:

Code:
<?php 
if (PAGE_ID == 123) {
 
MiniCounter("Hits: " " [Today: " "]" );
}
?>

thx!!!
Logged
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2294



WWW
« Reply #17 on: December 16, 2011, 10:47:04 AM »

Note that this way other pages will not be recorded at all.
If you also want to count those pages, but without display you could use:

Code:
<?php 
if (PAGE_ID == 123) {
 
MiniCounter("Hits: " " [Today: " "]" );
} else {
 
MiniCounter(0);
}
?>
Logged

Professional WebsiteBaker Solutions
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!