Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


psy last won the day on February 21

psy had the most liked content!

Community Reputation

559 Excellent


About psy

  • Rank
    Sr. Member

Contact Methods

  • Website URL

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

3,228 profile views
  1. Just throwing it out there and not the answer to all PW static site situations, but a PWA like https://www.pwabuilder.com/ may help. In my experience, there can be glitches between PWABuilder depending on the config chosen, and ProCache with too much unsynched caching. Definitely not the answer if your site has lots of forms and/or dynamic content, but for static sites that have dodgy internet connections it's definitely worth investigating.
  2. From @ryan's comment in the blog post https://processwire.com/blog/posts/webp-images-in-pw/: "By the way, if for some reason the webp results in a larger image (which is very rare), calling the $image->webp->url will return the smaller (non-webp) image." Very excited to see webp support in PW core then followed all the instructions. Couldn't get it working, or so I thought. Seems I did. OK, I take the craftsman's approach when adding images: Photoshop image as needed then reduce the image size to close to the max dimensions I need Export for Web Legacy - jpeg high @ 60% quality Drop exported jpeg into the lovely TinyBeest app https://www.tinybeest.com/ (Mac only) Upload TinyBeest-optimised image to PW, often output with MarkupSrcSet https://modules.processwire.com/modules/markup-src-set/ template code Every time I used $image->webp->url I got a jpg file with great quality. Only got webp when I uploaded the original image, often MB's huge. Bit frustrating that my images still get scored down on Google Page Speed Insights for not being webp - but then they'd be bigger and take longer to download 😂
  3. Good pick-up @wbmnfktr! /site/init.php is different to /site/templates/_init.php I guess the custom of using ready.php is that by that time, PW knows about the current page which in this case, is referenced in the hook.
  4. Hi @VeiJari It's usual practice, but not compulsory, to put hooks into /site/ready.php. site/ready.php loads before _init.php. You're changing the saved page data so you may need to turn off outputting formatting first if saving the entire page, or simply set-and-save the 'ajasta' field, eg (untested): wire()->addHookAfter('Pages::published', function($event) { $page = $event->arguments('page'); $t = wire()->templates->get($page->template); if($t->name == 'artikkeli' && $t->hasField("ajasta") { $page->setAndSave('ajasta', 0); } $event->return = $page; });
  5. I use LastPass because, just because it works for me. Haven't delved into other options. Tip: (also found elsewhere in the forum) When using a password manager, turn it off when editing a PW user profile
  6. Thanks @tpr I'm sure the answer is in there somewhere. ProcessWire & Google searched but that page didn't come up
  7. Thanks @tpr But won't that give me all pages? On the Business page, I only want to show pages that have 'Business' checked, whether on it's own or also checked with 'Individual'. What was my third choice? Only showed two 🤣 Second choice doesn't work via the API on select options fields
  8. I have a select options field that displays as multi-choice checkboxes. It's a required field and some pages have only one option selected, other pages have both selected, eg: Page 1: category = Business Page 2: category = Individual Page 3: category = Business and Individual Dilemma arises when I try to select pages that have both 'Business' and 'Individual' This codes works if I only want one choice: if ($page->id == 1055) { $services = $pages->get(1115)->children("category=Business"); } elseif ($page->id == 1113) { $services = $pages->get(1115)->children("category=Individual"); } BUT both $services result sets leave out Page 3. So I tried the following using the 'contains' selector which caused a page crash: if ($page->id == 1055) { $services = $pages->get(1115)->children("category*=Business"); } elseif ($page->id == 1113) { $services = $pages->get(1115)->children("category*=Individual"); } Any suggestions on how to write the selector to successfully retrieve pages that have both choices? Thanks psy Solution: The selector retrieves the value/id, not the title of the option if multiple, eg "1|2" rather than "Business|Individual". Changed it to: if ($page->id == 1055) { $services = $pages->get(1115)->children("category=1"); } elseif ($page->id == 1113) { $services = $pages->get(1115)->children("category=2"); } This covered the and/or scenario.
  9. psy

    My code

    A huge shout out thank you to all the PW developers who have, and continue to help me.
  10. @dab, yes, the PushAlert support team are almost as helpful as the PW devs here 😉 DON'T use the PushAlert sw.js file. It's the vanilla version and doesn't include the PW custom code to save subscriber ID's with PW user ID's. The module will automatically add sw.js + the custom function to the <head> for you. See my post to @dragan about this above. Also see the IMPORTANT section of the README about manifest.json. If you're site already has one, just add the gcm_sender_id code line.
  11. @dab Great it's now working for you. All credit to flydev for the fix 🙂 The reporting of "Attempted" rather than "Delivered" is a question for PushAlert support. Once PW sends the notification, it hands over to PushAlert and then catches the response to report the status.
  12. @flydev grateful for your patience with me on resolving this issue. Fixed in gitHub Working code is: $http->setHeader("Authorization", "api_key=". $this->api_key); Also updated the _getHttp function with same fix in gitHub
  13. @flydev Thanks again for the detailed feedback. My development site runs PW 3.0.124 so I don't understand why the behaviour would be different? C'est la vie. In version 3.0.124, Ryan introduced support for cURL in WireHttp https://processwire.com/blog/posts/pw-3.0.124-and-new-site/#wirehttp-updated-with-curl-support In the PushAlert.module I tried to take advantage of this new feature, from Line 439: // Prepare and send the request $slug = "send"; if($this->wire('config')->version('3.0.124')) { // ProcessWire version is 3.0.124 or newer $result = $this->_sendHttp($slug, $options); } else { $result = $this->_sendCurl($slug, $options); } return $result; } /** * @param $slug * @param $options * @return mixed */ private function _sendHttp ($slug, $options) { $http = new WireHttp(); $headers = Array(); $headers[] = "Authorization: api_key=". $this->api_key; $http->setHeaders( $headers); $result = $http->send($this->api_url . $slug, $options); return $result; } /** * @param $slug * @param $options * @return bool|string */ private function _sendCurl ($slug, $options) { $headers = Array(); $headers[] = "Authorization: api_key=" . $this->api_key; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->api_url . $slug); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($options)); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); return $result; } Because I cannot recreate the issue, would you please try commenting out lines 458, 459 & 460 and replacing them with: // $headers = Array(); // $headers[] = "Authorization: api_key=". $this->api_key; // $http->setHeaders( $headers); $http->setHeader("Authorization: api_key=". $this->api_key); and let me know if this resolves the issue. More: I used Array() in WireHttp to keep it consistent with the cURL method. Happy to change in the module _sendHttp method if WireHttp headers array works differently. Still wondering why it worked on my PW 3.0.124 and not for you...
  14. @flydev Great feedback and excellent suggestion. On the list for the next release 🙂
  15. @dab Thank you ☺️ The field creation bit is pure PW, not PushAlert related at all so not sure why this occurred but good to know about uppercase/lowercase in field names. The deletion of the pushalert_endpoint.php template is also pure PW/PHP as per the docs: https://processwire.com/api/ref/wire-file-tools/unlink/ // Delete the endpoint template file - should never be customised $templatePath = $this->wire('config')->paths->templates . "pushalert_endpoint.php"; if (is_file($templatePath)) $this->wire('files')->unlink($templatePath); Could it be a permissions error?
  • Create New...