Recently Updated Topics
Showing topics posted in for the last 7 days.
- Past hour
-
Fieldtype module does not trigger sleepValue() nor wakeupValue()
ryan replied to thei's topic in Module/Plugin Development
@thei I think the issue may be that the 'data' column isn't used here, and ProcessWire wants you to use it. So you could perhaps use 'data' as your "date_from" and then add another column called "to" or something, and use that as your "date_to". The only methods that would need to know about "data" and "to" would be those that communicate with the database: getDatabaseSchema(), wakeupValue() and sleepValue(). Everywhere else can refer to date_from and date_to. The wakeupValue would convert "data" and "to" to "date_from" and "date_to", while the sleepValue() would convert "date_from" to "data" and "date_to" to "to" (or whatever column names you decide to use). Example of the Fieldtype portion below: public function getBlankValue(Page $page, Field $field) { return [ 'date_from' => '', 'date_to' => '' ]; } public function getDatabaseSchema(Field $field) : array { $schema = parent::getDatabaseSchema($field); $schema['data'] = 'date default null'; // date_from $schema['to'] = 'date default null'; // date_to $schema['keys']['data'] = 'KEY data (`data`, `to`)'; $schema['keys']['to'] = 'KEY `to` (`to`)'; return $schema; } public function ___sleepValue(Page $page, Field $field, $value) { $value = $this->sanitizeValue($page, $field, $value); // store blank as null in DB if(empty($value['date_from'])) $value['date_from'] = null; if(empty($value['date_to'])) $value['date_to'] = null; // return value ready to store in DB return [ 'data' => $value['date_from'], 'to' => $value['date_to'] ]; } public function ___wakeupValue(Page $page, Field $field, $value) { if(!is_array($value)) return $this->getBlankValue($page, $field); // return value ready for $page->fieldName return [ 'date_from' => "$value[data]", 'date_to' => "$value[to]" ]; } public function sanitizeValue(Page $page, Field $field, $value) { if(!is_array($value)) $value = []; $value = array_merge($this->getBlankValue($page, $field), $value); $dateFrom = $value['date_from']; if($dateFrom) $dateFrom = wireDate('Y-m-d', $dateFrom); $dateTo = $value['date_to']; if($dateTo) $dateTo = wireDate('Y-m-d', $dateTo); return [ 'date_from' => $dateFrom, 'date_to' => $dateTo ]; } Next, I don't think your Inputfield processInput() method will work as-is, so I'd suggest changing it to something like this: public function ___processInput(WireInputData $input) { $value = [ 'date_from' => '', 'date_to' => '' ]; foreach(array_keys($value) as $key) { $date = $input->get($key); $value[$key] = $date ? wireDate('Y-m-d', $date) : ''; } $this->val($value); return $this; } Once you've got it all working, you might consider changing the array value to a WireData value. That will make it so that you only ever have to define the date_from/date_to array once, and it can sanitize itself rather than these other methods. - Yesterday
-
Happy 2026 everyone! ๐ TL;DR: I made 2048 game for ProcessWire admin. Install it, ignore your inbox, get high scores. Why? Because it's January 1st and: โ You're probably hungover โ Nobody expects you to work โ You're definitely checking your admin anyway โ Why not play some 2048 while you're there? What's inside? ๐ฎ Classic 2048 (arrow keys or swipe) ๐ Leaderboard (compete with your team!) ๐ Sound effects (mutable, we know your head hurts) ๐ฑ Works on phone (for bathroom breaks) โ๏ธ Configurable grid (3x3 to 12x12 if you hate yourself) Download https://github.com/mxmsmnv/Process2048 Install Upload to /site/modules/Process2048/ Modules โ Refresh โ Install Setup โ 2048 Start procrastinating! Screenshot: Cheers ๐ฅ
-
- 4
-
-
- Last week
-
As we close out 2025, I'm pleased to share a new module that I've been using in production: FieldtypeTimezone / InputfieldTimezone. ๐ฏ What It Does A straightforward timezone fieldtype that handles the complexity of timezones automatically - no configuration needed, just install and use. Key Features: Dynamic UTC offsets - automatically calculates current offsets with DST support Simple format - displays as "Country โ City (UTC+X)" Intelligent caching - 24-hour cache for optimal performance Production-ready - strict validation at all levels Complete coverage - all major world timezones included ๐ก Why I Built This Working on global websites (wine shop, news portal), I needed a reliable way to handle user timezones without complexity. The module automatically adjusts UTC offsets for DST: America/New_York: UTC-5 in winter, UTC-4 in summer Europe/London: UTC+0 in winter, UTC+1 in summer ๐ Basic Usage <?php // Display date in a nice English format $timezone = $page->tz; // e.g., "America/New_York" if ($timezone) { $tz = new \DateTimeZone($timezone); $datetime = new \DateTime('now', $tz); echo $datetime->format('F j, Y \a\t g:i A T'); } ?> Perfect for: User profiles with timezone preferences Event calendars with automatic time conversion Global applications requiring accurate time display Any site serving users across multiple timezones ๐ Requirements ProcessWire 3.0.0+ PHP 8.1+ ๐ฆ Installation GitHub: https://github.com/mxmsmnv/FieldtypeTimezone cd /path/to/processwire/site/modules/ git clone https://github.com/mxmsmnv/FieldtypeTimezone.git Or download and extract to /site/modules/FieldtypeTimezone/ Then install via Modules โ Site โ FieldtypeTimezone ๐ Documentation Full documentation with practical examples, API methods, and advanced usage scenarios is available in the GitHub repository. ๐ค Feedback Welcome The module has been tested in production on several sites, but I'd appreciate any feedback, suggestions, or bug reports from the community. Happy New Year to the ProcessWire community! ๐
-
- 10
-
-
-
Constant Contact is not the easiest mail provider to work with as a developer. Although I had hoped to use a different provider prior to our website relaunch that likely won't happen for quite some time. In the process, I created a module to handle the handshake keep-alive that Constant Contact requires so that I could use a very simple, customized single-field form to allow visitors to subscribe to our newsletter. I share this module now. NOTE: Installs SubscribeToConstantContactKeepAlive.module REQUIRES: LazyCron (for the KeepAlive module) SubscribeToConstantContact A lightweight module for the ProcessWire CMS/CMF that lets you subscribe a user to a Constant Contact list. Heavily inspired by SubscribeToMailchimp. The basic idea // Easily subscribe a user with SubscribeToConstantContact $mod = $modules->get("SubscribeToConstantContact"); $mod->subscribe('email@example.com'); How To Install Download the zip file at Github or clone the repo into your site/modules If you downloaded the zip file, extract it in your sites/modules directory. You might have to change the folder's name to 'SubscribeToConstantContact'. Go to the modules admin page, click on refresh and install it. This will also install the associated SubscribeToConstantContactKeepAlive module which is necessary for keeping the API active. Setup at Constant Contact Log into your Constant Contact account and go to the Developer Portal > My Applications (you may have to click a "log in" button again) and edit an existing, or create a new application using Authorization Code Flow and Implicit Flow, and rotating refresh tokens. Retrieve the API Key and Client Secret. NOTE: The client secret may need to be recreated to retrieve it. Module Setup Put the API Key and Client Secret into the module settings (Processwire > Modules > Site > SubscribeToConstantContact), and use the "Redirect URL" as printed on the module config screen for your Constant Contact API application's Redirect URI field value. Submit the form to save the values from this step. Click on the generated URL, "Authorize and connect this module to your Constant Contact Application," on the module configuration screen. Values have been retrieved from the Constant Contact API. Click "Submit" to save them to the module configuration. OPTIONAL: Choose a default contact list for the module to subscribe contacts to. Usage // load module into template $mod = $modules->get("SubscribeToConstantContact"); // subscribe / update a user in your default audience $mod->subscribe('email@example.com'); // add additional fields to fill out user data // subscribe($email, $list_id, $parameters) // $list_id will default to the module's saved configuration value, if set // NOTE: Parameter values are not validated by the module, see the documentation for further info $mod->subscribe('email@example.com', null, ['first_name' => 'John', 'last_name' => 'Doe']); // Subscribe a user to a specific list (other than default) $mod->subscribe('email@example.com', 'adcdef12345', ['first_name' => 'John', 'last_name' => 'Doe']); Additional methods // Unsubscribe a user $mod->unsubscribe('email@example.com'); // Delete a user. Deleted users still exist in Constant Contact, but cannot be seen (in Constant Contact) or retrieved (via API) $mod->delete('email@example.com'); // Unsubscribe a user from a contact list (or array of lists) $mod->removeFromList('email@example.com'); $mod->removeFromList('email@example.com', 'abcdef1356'); $mod->removeFromList('email@example.com', ['abcdef1356']); Example Example usage after a form is submitted on your page: // ... validation of form data $mod = $modules->get("SubscribeToConstantContact"); $user_email = $sanitizer->email($input->post->email); $mod->subscribe($user_email); Troubleshooting In case of trouble check your ProcessWire warning logs. FAQ I can't see the subscriber in the contact list If you have enabled double opt-in in your Constant Contact settings, you will not see the subscriber until the confirmation link in the email sent by Constant Contact has been used; the user may have also been deleted. I get an error in my ProcessWire warning logs Check if you have the proper contact list ID and API Key. Check if you pass a valid email address. Make sure LazyCron is installed Go to the Constant Contact Developer Documentation for more information. *I have only done minimal testing on this module, so use with caution, and please report any bugs related to the stated purpose of the module. Contribution Pull requests welcome. (Especially for the awkward module setup/configuration flow.)
-
- 1
-
-
Hi @loukote, good catch, you are right, arrays should be used instead of new WireData(...), which was a faulty leftover from the first version. Reason being is that since 2.0.0 these arrays are directly passed on to and processed in the ICSEvent class, which is written in pure PHP. Thanks for letting me know, I updated it everywhere, added more examples and did some minor improvements (create named files, types, cleanup). If you encounter any further problems don't hesitate to reach out again.
-
Hello @maximus Thanks for sharing! I will certainly give it a shot. Side note: the guys at LEGO "can get furious" when someone else uses their trademark in a way they consider inappropriate. As long as it is for something personal, that should be legally fine. I am not a lawyer, but letting us download your file in a forum post like this should be considered to be "for personal purposes". If you were to turn it into a "product" then that would be a different matter.
-
How to add spaces left and right for vertical images
maximus replied to maximus's topic in General Support
I'm back, happy to present a module that makes square images. https://github.com/mxmsmnv/SquareImages I welcome any feedback. -
I hope that you all had a nice winter holiday (Christmas, etc.) or are still on holiday till the new year. Not a lot to report this week since Iโve been on holiday too, but we finally launched that site thatโs been keeping me busy for the last few weeks, so Iโll hopefully be spending a lot more time in the core this coming week. I'll get the site posted to the sites directory once some more of the post-launch details are taken care of. One thing I learned in launching that site is that Markup File Regions work great during development, but not so great on a busy site (at least a site using Amazonโs EFS file system, which is very slow). I ran into all sorts of strange issues so ended up converting the file regions back to regular old static CSS and JS files, and then everything ran smoothly again. So as solid as the file regions are during development, they will need more work before I use or recommend them in production. Thatโs the way it goes with developing new stuff sometimes. There is however a pretty nice improvement to Markup Regions committed this week though. Prior there were some limitations as to what could populate what. Typically output before the <html> (i.e. from template files) populated into output that comes after the <html> (i.e. a _main.php file). But now it is possible for the population of content to go in either direction. Further, more nested elements can also populate less nested (or non-nested) elements. Itโs a little hard to explain, but basically, you donโt have to think too much about when and where you can populate things as Markup Regions will figure it out in the final output. This makes it even easier to use and hopefully more foolproof than before. Thanks for reading and have a great weekend!
-
- 20
-
-