Jump to content

visit counter works in 2.7.2 but NOT in 3.0.8 ?


EyeDentify
 Share

Recommended Posts

Hello all the nice PW people.

I am trying to work out why the following code of my visit counter:
 

<?PHP

/*
    simple code for recording current page visit count to its visit_counter field of "integer" type.
    But only if the visitor is not currently logged in.
*/

if($user->isLoggedin()) {
    
    /* if the user is logged in do not count visits */ 
    
} else {
    

    /* if the user is NOT logged in and not counted */

    /* turn of output formating so PW do not give an error when we change the value */
    $page->of(false);

    /* increment the current integer plus one */
    $page->visit_counter = $page->visit_counter + 1;

    /* save the visitor_counter field */
    $page->save('visit_counter');

    /* turn on output formating so PW work as it should */
    $page->of(true);
 
}
?>

Do not work in my 3.0.8 installation of ProcessWire.

It works in another website where i run 2.7.2 very well.

The field name is visit_counter and the type is Integer.
And the field is added to all the relevant templates.

Also tested editing the field in a page via admin and that updates and works. But not via the API it seems.

I include it at the top of my template files just under the BODY tag.

Have i missed anything ?

I am greatfull for all suggestions :) have gone a bit stir crazy trying to figure this out.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...