Jump to content

EyeDentify

Members
  • Posts

    160
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by EyeDentify

  1. Just adding my two cents here. Or "kronor" in my case cause i am from sweden. Anyways... I have allways made my own Slider implementation using the excellent Flickity slider from http://flickity.metafizzy.co/ It´s really great and easy to work with. Many config options and great support. I would just render out each image from the image field type and then use the built in crop or resize methods for thumbnails.
  2. Aha. So your saying that if the Session var is set then there is no counting ? And if there is no such Session var it is set and the count goes up one ? Just so i understand.
  3. Thanks for the tip @pwired. Had not thought about that before but it makes sens.
  4. Hello Everyone. This is not Strictly just about Processwire, but its something i use with a Processwire website that i created. It´s just a simple little Anti-spam protection system i use to make it more difficult for simple bots to mess around with a contact form on the said website. it seems to be working pretty well. The system is very simple, let me explain. Step 1 In the template file for the contact form have this code: <?PHP /* create a random integer.*/ $sendFormInteger = mt_rand(1000,9999); /* save the integer to session var using PW API or just go PHP vanilla */ $session->set('antispam_code', $sendFormInteger); ?> As you can see we just create a 4 digit integer and save it to a session var using Processwire $session API. https://processwire.com/api/variables/session/ Step two Also in your form have for example a label that display the code we created above, so the poster has to manually fill it out in a form field. For example like this: <label for="antispam_code">Anti spam code: <strong><?PHP echo($session->get('antispam_code')); ?></strong></label> <input type="text" name="antispam_code" value="" class="" placeholder="Fill in antispam code here" /> We simply echo out the code we saved in the session var into the label so the user can read it and then fill it out into our form field below the label. Step Three In the file or template that receives the form data put in a simple check like bellow: <?PHP /* sanitize our data and make sure its a integer */ $antispam_code = $sanitizer->int($input->post->antispam_code); /* check if the code we saved in the session var is equal to the one filled in the form and sent to us */ if($session->get('antispam_code') == $antispam_code) { /* if antispam code correct then delete it and go on */ $session->remove('antispam_code'); } else { /* if code is NOT correct then do something else */ } ?> More info on $sanitizer API: https://processwire.com/api/variables/sanitizer/ Just thought i share this technique with you all. I have no doubt that you could easily come up with something more advanced then a 4 digit integer that i use. My anti-spam system is set up so that it creates a new code everytime the form template is loaded. So it should be hard to guess unless they make the bot read the HTML and find the code in the label and make the bot fill out the correct form field before sending it. Happy coding.
  5. Hello Videokid. Thank you for your contribution. I would like however a little explanation how your version is different from mine so i could learn from it. I see the use of the $session API variable, but what use has it in your code example ? what does it do ? Thank you again.
  6. I would like to thank all the Nice people giving me likes for this post. It realy gives me encuragement to come up with future tutorials when i have something usefull to share.
  7. @cstevensjr thank you sir for the link. I have some good info to work with.
  8. Hello Everyone. My question is to the superior minds and Processwire gurus and developers here if it would be safe to straight up upgrade a 2.7.2 installation to the latest 3.x.x Dev version ? If so, any special things i should consider ? I have no third party modules installed. Its all core and vanilla Processwire. Thank you in advance.
  9. Thank you sir. I must say that i fell in love with Processwire when i discovered it by chance. My Autism makes it difficult for me to grasp concepts sometimes and with Wordpress i had a tough time. Put Processwire changed everything for me. It sounds silly byt its like a dream come true. Processwire totaly make sens to me and the way the API works and as a fan of jQuery i love the route Ryan Cramer took with it.
  10. Hello all PW fans. I wanted to contribute with a simple but short tutorial on how i created a simple visitor counter to have a rough estimate on what pages got visits on my website. This tutorial assumes that you have setup a field on your page template that you want to monitor with a name of visit_counter of the field type integer. I put this simple code together by reading some answers by the Excelent Ryan Cramer here on the forums and decided to make a few changes to his implementation. This is because i did not want the code to count my visits to the site if i was logged in. Instead the code shows the current pages visits if i am logged in, and hides it if i am not. Enough talking. Here is the code: <?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 */ echo("<p>Visits: {$page->visit_counter} st.</p>"); } else { /* if the user is NOT logged in */ /* get current visit counts and save them plus one */ /* 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++; /* save the visitor_counter field */ $page->save('visit_counter'); /* turn on output formating so PW work as it should */ $page->of(true); } ?> I also put this code in a PHP file by itself and named it _visit_counter.php so that i could easily include it in whatever page i want to monitor. You could potentialy expand this and make it more advanced. i would look at the "roles" and "user" section of the: http://cheatsheet.processwire.com Bonus Tip, in the PW admin go to your template that you have the field setup in and on the "advanced" tab look for the "List of fields to display in the admin Pagelist" section and in that field put: {title} - Visits: {visit_counter} This again assumes the fields name is visit_counter . Now in my page list in admin i can see the title followed by the number of visits. Handy This is my first post to these forums. And i will try to help out where i feel my abilites come to the rescue. Hope this helps anyone out there working with Processwire.
×
×
  • Create New...