WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: Ruud on August 20, 2008, 12:09:33 AM

Title: New Snippet: Mini Counter - Most popular pages
Post by: Ruud on August 20, 2008, 12:09:33 AM
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: [Select]
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

[gelöscht durch Administrator]
Title: Re: New Snippet: Mini Counter
Post by: vyni on August 20, 2008, 04: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
Title: Re: New Snippet: Mini Counter
Post by: aldus on August 20, 2008, 10:41:15 AM
Hello Ruud

A nice one :-)

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



Regards
Aldus



[gelöscht durch Administrator]
Title: Re: New Snippet: Mini Counter
Post by: Ruud on August 20, 2008, 10:56:46 AM
Hi Aldus,

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

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
Title: Re: New Snippet: Mini Counter
Post by: aldus on August 20, 2008, 11:01:12 AM
Hello Ruud

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

Regards
Aldus
Title: Re: New Snippet: Mini Counter - Most popular pages
Post by: Ruud on October 06, 2008, 10: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


[gelöscht durch Administrator]
Title: Re: New Snippet: Mini Counter - Most popular pages
Post by: erpe0812 on October 06, 2008, 05:38:41 PM
Hi Ruud

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

rgds

erpe
Title: Re: New Snippet: Mini Counter - Most popular pages
Post by: erpe0812 on October 06, 2008, 06:02:25 PM
Got it work  :-D

Testpage (http://www.rvb.bplaced.net/pages/code-2.php)

Thanks for that.

rgds

erpe
Title: Re: New Snippet: Mini Counter - Most popular pages
Post by: vyni on October 06, 2008, 06: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
Title: Re: New Snippet: Mini Counter - Most popular pages
Post by: Ruud on October 06, 2008, 09: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.  :-D

Ruud


Title: Re: New Snippet: Mini Counter - Most popular pages
Post by: daydreamer on May 17, 2009, 11:04:13 AM
Is there a way to count unique visits only , Also not count search engines

Thanks
Title: Re: New Snippet: Mini Counter - Most popular pages
Post by: Ruud on May 17, 2009, 12:04:41 PM
No,

There is a reason this snippet is called minicounter ;-)

Have a look at this (http://www.websitebakers.com/pages/others/chcounter.php), this is a full counter with nice statistics.
Here (https://forum.WebsiteBaker.org/index.php/topic,4393.msg27275.html#msg27275) it is explained how to use it.

Ruud
Title: Re: New Snippet: Mini Counter - Most popular pages
Post by: solbu on April 04, 2010, 08:59:06 PM
Is there a way to reset the counter?
Title: Re: New Snippet: Mini Counter - Most popular pages
Post by: Ruud on April 04, 2010, 09:47:42 PM
Just uninstall and install a fresh one.

That should do the trick
Title: Re: New Snippet: Mini Counter - Most popular pages
Post by: flaens on December 16, 2011, 08:21:16 AM
hi,
is it possible to show the counter just on one page?
Title: Re: New Snippet: Mini Counter - Most popular pages
Post by: Ruud 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: [Select]
<?php 
if (PAGE_ID == 123) {
 
MiniCounter("Hits: " " [Today: " "]" );
}
?>
Title: Re: New Snippet: Mini Counter - Most popular pages
Post by: flaens 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: [Select]
<?php 
if (PAGE_ID == 123) {
 
MiniCounter("Hits: " " [Today: " "]" );
}
?>

thx!!!
Title: Re: New Snippet: Mini Counter - Most popular pages
Post by: Ruud 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: [Select]
<?php 
if (PAGE_ID == 123) {
 
MiniCounter("Hits: " " [Today: " "]" );
} else {
 
MiniCounter(0);
}
?>