Login to download the latest version of Mint and your favorite Pepper, purchase additional licenses, or post in the Forum. Don't have an account? Create one!

In Partnership with Media Temple

Mint Forum

Big Total Pepper almost done...

Sam Parkinson
Third-Party Pepper Developer
Posted on Feb 14, '08 at 06:51 pm

Hi,

I’ve just made a quick pepper that shows the number of visits that mint is currently holding. It uses most of Brandon Kelly’s Countertop Pepper (hope you don’t mind, you in the source comments btw).

Anyway so far its working fine, however as you’d expect the numbers come out in a format like ‘10000000’.

What I’m thinking would be nice is for it to look like ‘10,000,000’. Give the pepper a real nice look.

I’m really new to php so this is all a bit over my head, any ideas about how I would achieve this format?

Brad Jasper
Third-Party Pepper Developer
Posted on Feb 14, '08 at 11:15 pm

Give number_format() a try: http://us.php.net/number_format

Sam Parkinson
Third-Party Pepper Developer
Posted on Feb 15, '08 at 11:47 am

Well it’s finished.

I had a got at using the $this->data …

To get both the total and unique numbers but yea, i’m still a bit new to php.

Anyway I have the total page views working and formatted.

If anyone is willing to show me how I can get the unique data another tab could easily be added.

URL coming soon…

Sam Brown
Third-Party Pepper Developer
Posted on Feb 16, '08 at 04:54 am

Looking forward to this one R3morse!

Sam Parkinson
Third-Party Pepper Developer
Posted on Feb 16, '08 at 05:19 am

Thanks,

Right there’s a preview available on my mint at xseria.com/mint you may see a few changes from day to day as I’m having problems with the referrers…

I just realised that mint actually record’s the total hits & unique in the _config table!

This is what I have at the moment to use this new thing I found:

function visitTotal()

{
    $visits = $this->Mint->data['visits'];

    $everArr = array
    (
        @number_format($visits[0][0]['total']),
        $this->Mint->formatDateRelative($this->Mint->cfg['installDate'], 'month', 1)
    );

    $everArr[]  = ($everArr[0] > 1) ? 's' : '';

    return "<div style='text-align: center; padding: 2px 0;'><span style='font-size: 5em; line-height: 1.2em;'>{$everArr[0]}</span><br />Total visits since {$everArr[1]}</div>";

However as all you guru’s can probably guess this comes up with ‘0’, what am I missing (ignoring the fact its commented, im not that stupid… :P)???

Once I got this sorted I can easily make the unique tab as well, making this pepper a bit more useful. God I wish I new php.

You must be logged in to reply. Login above or create an account