Jump to content

SamC

Members
  • Posts

    733
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by SamC

  1. A $5 crysis has taken precedence over my module development tonight!
  2. @rick yeah, I can see the changes now on the page when I change things inside the ___execute() methods. The part that I was changing was here: public static function getModuleinfo() { return [ "title" => "Simple admin example", "summary" => "No need to be afraid of building custom admin pages.", "author" => SamC", "version" => 1, // page that you want created to execute this module "page" => [ // your page will be online at /processwire/simple/ "name" => "test", // <<<<<<<<< I CHANGED THE PATH HERE // page title for this admin-page "title" => "Hello", ], ]; } Had to uninstall and reinstall for this change to be reflected. Anyway, getting sidetracked as usual. I was thinking of just having the comments button, no need to load it up all the time. Not sure how people would even use it but I needed a reason to make a module, and here it is
  3. Some great resources to get me started, thanks! Following this one at the moment: https://processwire.com/blog/posts/building-custom-admin-pages-with-process-modules/ One thing, how I do I see changes in the module as I go along? When I make a change, I tried clearing cache but changes are not reflected, specifically, the page created in the getModuleInfo() method, for me at '/login/test/'. I changed the path in my code but the only thing that's worked so far was uninstall > reinstall. Is there an easier way?
  4. And the paid ones at: https://pixelarity.com/ Very nice designs but not used any myself though.
  5. I was going to add comments to my site and wanted to use disqus. I looked through the manual adding of this but thought this might be a good opportunity to learn how to make a module as I can't find one in the directory. Was thinking having a few fields or something, where config options can be set and they are then output somehow into the JS embed code. Not really sure about how any of it would work yet but gotta start somewhere. You'll notice on the disqus page that many other CMSs have dedicated plugins/modules to install it, so I'm looking to create the PW one. The manual instructions for disqus are here: https://help.disqus.com/customer/portal/articles/472097-universal-embed-code My immediate problem is, what category is a module like this? And what class would I extend? 'extends Process', 'extendsWireData' etc. It's not clear to me on the api page how you'd choose and reading the code from the base classes probably wont switch on any lights here. https://processwire.com/api/ref/module/ Maybe I'm biting off a little more than I can chew, but what the hell, it'll be a good learning experience, and maybe produce something useful at the end of it. I'll be digging into @bernhards process module tutorial this weekend but I don't think this is a process module.
  6. Just started using vscode yesterday, been using ST3 for a number of years. I tried atom but it was just so slow I couldn't cope with it. Lots of nice tips here thanks.
  7. This totally. If you install via npm you can use gulp to compile the scss. Create your own variables file, @import that, then @import whatever components you want, finally @import your custom styles. It's worth noting though, that although you can pull in 'just' a few components, on their own, these components are still a fair bit larger than a lean custom solution. I'm actually moving away from BS4 to Uikit 3 because it's more modular and I quite liked it after mucking around with the new admin theme. Hi @pwuser1 and welcome. Yes, css grid is responsive. Check out this pen (not mine): In all honesty, I wouldn't worry about css grid right now. It's just too new. Flexbox has only just gained enough browser support for me to switch over from floats (I loved bourbon/neat combo, alas, the new neat is still floats). But that combo gave me some super lean HTML markup,100% mixin based! No harm in learning it though for when it's ready for prime time, this is quite fun: http://cssgridgarden.com/
  8. I read the opening post earlier and I was like wha? Just now I loaded up my localhost pw.tuts.dev and BOOM! "Your connection is not private". The same damn site I was working on like 6hrs ago without issue. Now I gotta change my hosts and vhosts and all that crap. Looks like I'll be going down the .local route. Thanks for the answers here everyone.
  9. Absolutely this, I like it! I couldn't work out the use for it, I see now. Thanks
  10. I'm writing a tutorial about URL segments and I have it working like this (ignore overly verbose comments). Cats (cat-index template) - cat 1 (cat-entry template) - cat 2 - cat 3 Type (cat-attribute template, each child is a page ref field on cat-entry template) - Burmese (cat-attribute template) - Tabby - Persian - etc. Invalid is 2nd URL segment and anything else in URL segment 1 that isn't the page name under /type/. Valid /cats/tabby/ /cats/persian/ etc... Invalid /cats/first/ /cats/first/second/ <?php // only 1 URL segment should be allowed if ($input->urlSegment2) { throw new Wire404Exception(); } // create a string that will be our selector $selector = "template=cat-entry"; // get URL segment 1 $segment1 = $input->urlSegment1; // if there is a URL segment 1 if ($segment1) { // get array of cat type page names $catTypes = $pages->get("/type/")->children->each("name"); // name may be assumed here, not sure // if URL segment 1 is in cat types array if (in_array($segment1, $catTypes)) { // add this to the selector $selector .= ",catType=$segment1"; } else { // invlid URL segment 1 throw new Wire404Exception(); } } // find the pages based on our selector $catPages = $pages->find($selector); foreach ($catPages as $catPage): ?> Now this works, 404 for anything invalid. But I was looking at https://processwire.com/api/ref/wire-array/has/ and it seems to be similar. Is the code above a suitable way to achieve this? (bearing in mind this is a tutorial so trying to stick with best practices) And how would I use has() in the above example? Not 100% how to use that method i.e. is ->has() used inside a loop? (unfortunately can't link to the actual tut as it's unpublished)
  11. Picked up grim fandango yesterday! Got Oddworld: Abe's Oddysee for free a few months back. Use emulation station + retroarch for those Megadrive/SNES/Gameboy/MAME/PS1 games. Love me some retro gaming!
  12. I see the point, but I would personally expect a page /product-categories/ and the same at /skin-concerns/ which lists the actual menu items (in the right sidebar) but if they're not there by design then URL segments are win
  13. I guess it depends on how you expect to find visitors. Imagine spending a few days trying to optimize for pagespeed to please almighty google (and maybe get some random tyre kicker search visitors), then think that you could have done a facebook/twitter campaign, or even physically went out to find customers in that same time instead and maybe get some serious leads. For what I'm doing, word of mouth is going to be far more important than shaving a few milliseconds off pagespeed. You just have to use your time wisely, if pagespeed is important and will benefit you directly, then sink a few days into it. ps if you find a way to ever get rid of "Eliminate render-blocking JavaScript and CSS in above-the-fold content", then please let me know. Inline css is bad, let's use separate stylesheet files. Actually let's combine them into one file, and let's minimize them. No, let's use webpack to use JS to pull in CSS inline. No, let's just load a small part of CSS 'above the fold' and the load the rest later. What about smart watches? At this rate, we don't need to worry about IPv4 running out, everyone's too busy optimizing existing sites and learning tools to make anything new.
  14. Hi @szabesz thanks for the example. What would be wrong with 'product-categories/body-care' and 'skin-concerns/body-care'? Body care is the same only in name, they have different parents. Nice site btw
  15. Ok, thanks for the suggestions, I'll get tracy fired up tomorrow and see how I get on.
  16. I was just looking over this one again a minute ago and may be useful here regarding how to structure the pages:
  17. Hi @adrian to be fair, I haven't really sat down and tried to learn it properly. When I do this, I could always document it and use what I learned for a small tutorial for beginners. I'm seeing most things I do in this way at the moment and I've found that documenting stuff really increases the solidness of what I've learnt, it sticks, no forgetting it two weeks later. Right now I'm constructing a tut about URL segments. However, because the page tree most of the time matches the natural URLs for a site, I'm finding it tricky to even find a use case!
  18. How do I combine the two? Like this: $message = $sanitizer->entities($sanitizer->textarea($input->post->message)) ...or like: $message = $sanitizer->textarea($sanitizer->entities($input->post->message)); Or do you do it one at a time?
  19. I wrote a tutorial about this as I was involved in a thread here regarding the 'Add New' button. The tutorial is here and thread was: Maybe these will shed a bit more light. You can use this to add new pages via the template family settings (see links above)
  20. I've used: https://processwire.com/api/ref/sanitizer/textarea/ However, I'm not 100% sure of the security of this. It's a multi line text area on a contact form so someone could paste anything in there. Should I also run it through $sanitizer->entities? I'm gonna try throwing a few things in there and see what the resulting email is. Very technical I know.
  21. I know this an old thread, but can this be explained a bit more. I'm writing a tutorial about URL segments and this could be useful. I ask this because I can foresee the manual building of URLs to demonstrate how URL segments work. Although this would suffice for the tutorial, I'm curious about this hook as I'm getting more into PW now.
  22. I'm on 3.0.84 now and the 'Add New' is in the Pages dropdown. I just checked on a 3.0.41 installation I have the add new is also in the dropdown. Haven't got a 3.0.62 installation unfortunately.
  23. @vadimmil nice work! I don't understand a word of it but it looks very clearly laid out.
  24. I've only just noticed but I have a rather serious problem in that my webform cuts off the message text. Not sure why this is happening so any fresh eyes to look at this would be appreciated! contact.php: <?php namespace ProcessWire; wireIncludeFile("./vendor/vlucas/valitron/src/Valitron/Validator.php"); $captcha = $modules->get("MarkupGoogleRecaptcha"); $contactPageID = "1022"; $contactFormRecipient = "MY_EMAIL"; $name = $sanitizer->text($input->post->name); $email = $sanitizer->email($input->post->email); $message = $sanitizer->text($input->post->message); $v = new \Valitron\Validator(array( "name" => $name, "email" => $email, "message" => $message ) ); $v->rule("required", ["name", "email", "message"]); $v->rule("email", "email"); if ($input->post->sendMe) { if ($v->validate()) { if ($captcha->verifyResponse() === true) { $message = " <html> <body> <p><b>Customer name:</b> {$name}</p> <p><b>Customer email:</b> {$email}</p> <p><b>Customer message:</b></p> <p>{$message}</p> </body> </html> "; $mail = wireMail(); $mail->to($contactFormRecipient) ->from($email, $name) ->subject('Website form submission') ->bodyHTML($message); if ($mail->send()) { $session->flashMessage = "Thanks for your message! I will get back to you shortly."; $session->sent = true; $session->redirect($pages->get($contactPageID)->url); } else { $session->flashMessage = "Sorry, an error occured. Please try again."; } } else { $session->flashMessage = 'Recaptcha must be complete.'; } } else { $session->flashMessage = 'Please fill out the fields correctly.'; } } ?> <div id="form-top" class="mb-5"></div> <div class="container"> <div class="row justify-content-center py-5"> <div class="col-md-10"> <?php if($session->flashMessage):?> <div class="alert <?php echo $session->sent ? 'alert-success' : 'alert-danger'?>" role="alert"> <?php echo $session->flashMessage;?> </div> <?php endif;?> <form id="contact-form" method="post" action="#form-top"> <div class="row"> <div class="form-group col-sm-12 col-lg-6 py-2 <?php echo $v->errors('name') ? 'has-danger' : ''?>"> <label for="name">Name (required)</label> <input class="form-control" name="name" id="name" type="text" value="<?php if ($name) echo $name; ?>"> </div> <div class="form-group col-sm-12 col-lg-6 py-2 <?php echo $v->errors('email') ? 'has-danger' : ''?>"> <label for="email">Email (required)</label> <input class="form-control" name="email" id="email" type="text" value="<?php if ($email) echo $email; ?>"> </div> </div> <div class="form-group py-2 <?php echo $v->errors('message') ? 'has-danger' : ''?>"> <label for="message">Message (required)</label> <textarea class="form-control" name="message" id="message" rows="8"><?php if ($message) echo $message; ?></textarea> </div> <div> <label for="recaptcha">Recaptcha (required)</label> <!-- Google Recaptcha code START --> <?php echo $captcha->render(); ?> <!-- Google Recaptcha code END --> </div> <div class="form-group"> <button type="submit" class="btn outlined" name="sendMe" value="1">Enquire now!</button> </div> </form> </div> </div> </div> <?php $session->remove('flashMessage'); $session->sent = false; echo $captcha->getScript(); ?> If I submit: The form emails this: Any ideas why this would be happening? Thanks. += EDIT == Removing the sanitizer 'fixed' it. $name = $sanitizer->text($input->post->name); $email = $sanitizer->email($input->post->email); // $message = $sanitizer->text($input->post->message); <<< fail $message = $input->post->message; // works but not sanitized, bad! If I read here: https://processwire.com/api/variables/sanitizer/ Which is a suitable sanitizer for this field? This one? http://cheatsheet.processwire.com/sanitizer/properties-and-methods/sanitizer-textarea-value/
×
×
  • Create New...