Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/16/2025 in Posts

  1. This week we’ve got 2 new versions out: 3.0.246 on the main/master branch, and 3.0.247 on the dev branch. Version 3.0.246 (main/master) contains several minor bug fixes that were discovered after 3.0.244. And 3.0.247 on the dev branch adds support for conditional hooks that can match method return values. The hooks documentation has been updated with a new section that covers all the details here. I’m going to slow a bit on core updates over the next few weeks so that I can dedicate more time to developing the new ProcessWire website. The designers have done a great job and now I need to focus on getting some parts of it developed and new text written, etc. I’ll keep you up-to-date as it moves forward. Thanks for reading and have a great weekend!
    3 points
  2. Ever felt like your ProcessWire emails look like they're stuck in 1999? You know the drill - sending emails is super easy with WireMail: $m = new WireMail(); $m->from('foo@bar.com'); $m->to('xxx@yyy.com'); $m->subject('Hello there!'); $m->bodyHTML('<h1>This is great!</h1><p>I am an ugly mail...</p>'); $m->send(); But let's be honest - they look about as pretty as a website built with Microsoft FrontPage! 😅 🪄 Enter the Mail Pimp Hook! Drop this magical hook into your /site/ready.php (or even better Site.module.php), and watch your emails transform from ugly ducklings into beautiful swans: <?php $wire->addHookBefore('WireMail::send', function(HookEvent $event) { // double check that we got a wiremail instance // this also tells the IDE what $mail is (to get IntelliSense) $mail = $event->object; if (!$mail instanceof WireMail) return; // get current mail body $html = $mail->get('bodyHTML'); if (!$html) return; // get email layout markup $layoutFile = wire()->config->paths->templates . 'mails/default.html'; if (!is_file($layoutFile)) return; // replace ##content## with actual mail content $html = str_replace( '##content##', $html, wire()->files->render($layoutFile) ); // write new body to mail $mail->bodyHTML($html); }); The HTML Just create a beautiful MJML template at /site/templates/mails/default.mjml, put ##content## where your email content should go, convert it to HTML and BOOM! 💥 Every email gets automatically wrapped in your gorgeous template. No more CSS wrestling matches, no more "Why does this look different in Outlook?" headaches. Just pure email beauty, automagically! ✨ Now your clients will think you spent days crafting those emails, when in reality, you're sipping coffee while your hook does all the heavy lifting. Work smarter, not harder! 🚀 #ProcessWire #EmailMagic #NoMoreUglyEmails PS: This is the MJML template that I used: <mjml> <mj-head> <mj-attributes> <mj-all font-family="Tahoma" /> <mj-text line-height="140%" /> </mj-attributes> </mj-head> <mj-body background-color="#efefef"> <mj-section background-color="#ffffff" background-repeat="repeat" padding-bottom="30px" padding-top="30px" text-align="center" > <mj-column> <mj-image align="center" padding="25px" src="xxx" target="_blank" width="200px" alt="Logo" ></mj-image> <mj-text>##content##</mj-text> </mj-column> </mj-section> <mj-section> <mj-column> <mj-text font-size="10px" color="#a0a0a0" align="center" > powered by <a href="https://www.baumrock.com/" style="color: #158f66" >baumrock.com</a > </mj-text> </mj-column> </mj-section> </mj-body> </mjml> VSCode has an extension to get a live preview and export MJML to HTML: And here are some other free templates: https://mjml.io/templates I use https://www.base64-image.de/ to add the logo to my mail template as src="data:image/jpeg;base64,/9j/4QAWRXhpZgAATU0AKgAAAA..." to avoid headaches with image paths, remote assets blocking etc.
    1 point
  3. @ryan, is there any difference in terms of performance between using conditional hooks and doing the equivalent logic of checking the arguments and/or return value within the hook and returning early when a condition is not met? Personally I've preferred not to use the conditional hook syntax because I find it more readable to have PHP logic in the hook code, but if this was less performant I'd consider changing.
    1 point
  4. I ended up using a custom image field as required for the image description to add some notes too. With the following hook on ready.php, I just copy the custom image field description value to the native description field so it can be displayed as alt attribute on RTE images. The native description field no need to be displayed in the editor. It can be as 0 on "Number of rows for description field?" $wire->addHookBefore('Pages::saveReady', function($event) { $page = $event->arguments('page'); if ($page->template->name != "my-template") return; foreach($page->images as $image) { $image->description = $image->image_description; } });
    1 point
  5. I found that all I needed at the end of my config.php was $config->dbInitCommand = "SET time_zone = '+08:00' "; and all is good, warning gone. Thanks again.
    1 point
  6. Not that RSS ever actually died for us dev types, but it did for regular users. I don't want to get political here because it's not appropriate for these forums, but if anyone is considering removing X/Twitter from their projects, I am seeing that there is some momentum building to bring RSS back to the masses. I remember in the 2000's every site had an RSS feed and email clients supported them - they are a brilliant way to bring the news sources you care about into one place. Of course Google, Apple, Twitter, Meta etc didn't like this because it meant users could read the content they wanted without an algorithm having control and ads being served, so Google Reader was killed off, Apple removed RSS support from Mac Mail, etc. I have continued to use RSS (although less than I used to), but I am now fully back on board and convincing clients to add them to their sites. https://aboutfeeds.com/ is a good resource for those who know nothing about RSS and https://hvandenbergh.medium.com/back-to-rss-e4e177314bc3 is a short read about why RSS is good for the user is this day and age. Spread the word! And as a side note, for those of you who use UIKit, here is a nice little tweak to make their RSS icon actually look decent and match UiKit's other social media icons. /* Fixed the ugly UIKIT RSS icon */ .uk-icon[uk-icon*="icon: rss"] svg path { stroke-width: 3.5; stroke-linecap: round; } .uk-icon[uk-icon*="icon: rss"] svg { transform: scale(0.85); } .uk-icon[uk-icon*="icon: rss"] svg circle { transform: scale(1.2); transform-origin: 0% 100%; /* Scale from the bottom-left corner */ } instead of
    1 point
  7. Version 2.2.14 is out! This new version comes with a new CAPTCHA type: a slider captcha. Now FrontendForms supports 7(!) different CAPTCHA types and I guess this will be the last one. There is a fabulous module in the module directory which also creates a slider captcha that can be used with other forms: Slide Captcha. But the slider Captcha in FrontendForms is an extra coded and integrated captcha, that has nothing to do with this module. To be clear: The slider captcha inside FrontendForms is similiar to the Slide Captcha module, but it has nothing to do with it. So there is no need to install the other module. The only thing you have to do is to enable the slider captcha in the module configuration - that is all. You have 1 additional configuration field where you can select the accuracy of the puzzle piece to the goal. 5 means that the distance of the puzzle pieces to the target must be less than or equal to 5px in order to solve the captcha correctly. Here you can see the new slider captcha in action: As always, please report any bugs on Github!
    1 point
  8. ProcessWire has language alternate fields, which basically do what you describe out of the box. Unlike multi-language fields, language alternate fields can also be used with image fields.
    1 point
×
×
  • Create New...