EyeDentify Posted February 15, 2016 Posted February 15, 2016 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.
WillyC Posted February 15, 2016 Posted February 15, 2016 u.haves anee caches ? likes tamplate cache on ? 1
pwired Posted February 15, 2016 Posted February 15, 2016 Have you tried adrian's brand new debugger module ? https://processwire.com/talk/topic/12208-tracy-debugger/ 1
EyeDentify Posted February 15, 2016 Author Posted February 15, 2016 Thank you for all your tips.For some reason it now seems to be working. I am going to keep an eye on it.Could it be cache related and the cache was cleared after a while and now it works ?
EyeDentify Posted February 15, 2016 Author Posted February 15, 2016 Quick update.I checked all the templates cache setting and it is not enabled so it can´t be the cache ?Maybe session related ?
EyeDentify Posted February 15, 2016 Author Posted February 15, 2016 Well it seems to work so far as i can tell. i Declear this solved.Will reopen if things changes.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now