WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.8 is now available!


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • New Snippet: Mini Counter - Most popular pages
  • Print
Pages: [1]   Go Down

Author Topic: New Snippet: Mini Counter - Most popular pages  (Read 35782 times)

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
New Snippet: Mini Counter - Most popular pages
« 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(1 , "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]
« Last Edit: October 06, 2008, 09:48:54 PM by Ruud »
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

vyni

  • Guest
Re: New Snippet: Mini Counter
« Reply #1 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
Logged

aldus

  • Guest
Re: New Snippet: Mini Counter
« Reply #2 on: August 20, 2008, 10:41:15 AM »
Hello Ruud

A nice one :-)

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



[gelöscht durch Administrator]
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: New Snippet: Mini Counter
« Reply #3 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
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

aldus

  • Guest
Re: New Snippet: Mini Counter
« Reply #4 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
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: New Snippet: Mini Counter - Most popular pages
« Reply #5 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]
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

erpe0812

  • Guest
Re: New Snippet: Mini Counter - Most popular pages
« Reply #6 on: October 06, 2008, 05:38:41 PM »
Hi Ruud

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

rgds

erpe
Logged

erpe0812

  • Guest
Re: New Snippet: Mini Counter - Most popular pages
« Reply #7 on: October 06, 2008, 06:02:25 PM »
Got it work  :-D

Testpage

Thanks for that.

rgds

erpe
Logged

vyni

  • Guest
Re: New Snippet: Mini Counter - Most popular pages
« Reply #8 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
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: New Snippet: Mini Counter - Most popular pages
« Reply #9 on: October 06, 2008, 09:43:40 PM »
Quote from: vyni on October 06, 2008, 06:05:27 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


Logged
Dev4me - WebsiteBaker modules - WBhelp.org

daydreamer

  • Guest
Re: New Snippet: Mini Counter - Most popular pages
« Reply #10 on: May 17, 2009, 11:04:13 AM »
Is there a way to count unique visits only , Also not count search engines

Thanks
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: New Snippet: Mini Counter - Most popular pages
« Reply #11 on: May 17, 2009, 12:04:41 PM »
No,

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

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

Ruud
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

solbu

  • Guest
Re: New Snippet: Mini Counter - Most popular pages
« Reply #12 on: April 04, 2010, 08:59:06 PM »
Is there a way to reset the counter?
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: New Snippet: Mini Counter - Most popular pages
« Reply #13 on: April 04, 2010, 09:47:42 PM »
Just uninstall and install a fresh one.

That should do the trick
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

flaens

  • Guest
Re: New Snippet: Mini Counter - Most popular pages
« Reply #14 on: December 16, 2011, 08:21:16 AM »
hi,
is it possible to show the counter just on one page?
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: New Snippet: Mini Counter - Most popular pages
« 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: [Select]
<?php 
if (PAGE_ID == 123) {
 
MiniCounter(1 , "Hits: " , " [Today: " , "]" );
}
?>
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

flaens

  • Guest
Re: New Snippet: Mini Counter - Most popular pages
« Reply #16 on: December 16, 2011, 10:35:05 AM »
Quote from: 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(1 , "Hits: " , " [Today: " , "]" );
}
?>

thx!!!
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: New Snippet: Mini Counter - Most popular pages
« 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: [Select]
<?php 
if (PAGE_ID == 123) {
 
MiniCounter(1 , "Hits: " , " [Today: " , "]" );
} else {
 
MiniCounter(0);
}
?>
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • New Snippet: Mini Counter - Most popular pages
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2