Introduction
Words, light switches, performant templates and a sprig.
Hello Craft friends. We’ve got another issue of links covering a wide range of Craft-related and Craft-adjacent topics.
Ben Croker’s Sprig is definitely worth your time. Ben also gave a presentation on writing Twig templates focusing on performance. We'll dive into the lightswitch field and how its default field values work. Plus, there are news items on the latest Craft releases, tips, plugins, and more. I hope you find something to dig into.
Thank you to the sponsors of this issue.
Retour from nystudio107 helps you maintain the SEO of your links even when the URL changes.
Freeform is the feature-filled form plugin for Craft CMS that includes ready-to-use templates to get you up and running quickly. Learn about the power of Freeform.
Let’s hit the links.
-John Morton
Top Stories
Words matter ⭐️⭐️⭐️⭐️
Yii has updated terminology in the language, thanks to a pull request from Brandon. This change is part of the movement to use more inclusive language in the tech industry. For context, see this Washington Post piece, this story on naming convention changes at Github, and this Tweet. Bravo!
News
Craft 3.4.23 released
Version 3.4.23 reverses a change to database configurations that happened in the Craft 3.4.0. In short, in that release, Craft deprecated the DbConfig.php
file in favor os a dsn
string in the .env
file. Now, as you can read in the change log, “ The setup command and web-based installer now set DB_DRIVER
, DB_SERVER
, DB_PORT
, and DB_DATABASE
environment variables, if a DB_DSN
environment variable isn’t already defined.“
Craft 3.5 Beta 3 released
The Craft 3.5 betas keep coming in. What’s new?
- Save & create new entry shortcut
- No more “Deleting stale template caches” task
- Easily fetch localized versions of elements
- New “Explorer” pane for GraphiQL
- “Underline links” user pref
Featured Sponsor

Retour - Intelligent 404 redirect handling
Retour allows you to intelligently redirect legacy URLs, so that you don’t lose SEO value when rebuilding & restructuring a website
Tools, tips, and fundamentals

Drag and Drop on an Assets field? Yes we can.
Once you discover this UX-nicety, you may never use the file dialog box again.
Can I add an enabled-by-default lightswitch field to existing entries?
Adding a lightswitch field that has a default value of true
to an entry type with a set of existing entries results in some potentially unexpected behavior. New entries will have the lightswitch field with the default value in the database of 1
, i.e., true
. But what happens to the existing entries? In the database, the lightswitch value will be null
for those entries.
You can deal with this as this Stack Exchange post linked above says, or, as Steve Rowling mentioned in Discord last week, "If you're familiar with SQL, you can do this [updating the old entries with your preferred default value] directly on the database. Much quicker than re-saving all entries."
You might not need to do this at all in Craft 3. Check out the recently updated docs on the lightswitch field:
Lightswitch field values are now always
true
orfalse
. If you’re accessing a Lightswitch field value for an element that doesn’t have an explicit value set yet, the field’s default value will be returned instead.
Likewise, Lightswitch fields’ element query parameters will treat null
values as if they were set to the default value, so .myLightswitchField(true)
will return entries where the field is either enabled or null (assuming the default value is enabled and set to true
). This change happened recently in Craft 3.3.
Thanks to Brandon for helping me with the details.
Four links on licensing
If you’re new to Craft and come from a “free” CMS like Wordpress, you might have licensing questions. (Yes, the “free” being in quotes is intentional.) The four links below cover all of those questions in detail.
Using Feed Me in your Templates
John Baxter mentioned that you can use Feed Me to do more than just create elements from data. You can also pull in external data into you site, something I would typically use Javascript to do.
As an example, Sean Smith uses Feed Me to fetch the RSS feed from his podcast to display an episode list on his site. The list is displayed on the site, but no entry is created.
How can I tell if a variable is an array or an entry/element query?
Read the Stack Exchange for the specifics of the use case and then head over to the docs and read about the instanceOf test.
Perfecting your technique
Templating for Performance in Craft with Ben Croker ⭐️
This is a recording of the Templating for Performance in Craft presentation by Ben Croker at the most recent London Craft CMS Meetup. Here is a link to the Craft templates Ben used during the presentation.
Notes on identifying a hacked server
The notes linked above were shared in Discord last week to outline the steps taken to "fix" a compromised server, infected with cryptocurrency mining malware.
The server is thought to have been compromised through an unpatched SEOmatic installation. SEOmatic 3.3.0, released on April 28, 2020, included a patch for this potential exploit, but last week the “critical” designation was added to that release to highlight its importance. If you have not patched SEOmatic, you should do so now.
The unfortunate news is that with any exploit, there's no way of knowing exactly what a hacker might have tried to do to a compromised server. The safest course would be to move your site to a newly built server.
This serves as reminder #239843247 to keep your software updated. Software is rarely perfect and hackers never sleep.
Headless CMS Break Down & Roundup — Syntax Podcast 254
The Syntax team goes through a long list of CMS options. If you want to skip to where Craft CMS gets mentioned, skip to the 39-minutes point.
Craft Commerce Subscriptions on CraftQuest
Learn how to use the Craft Commerce subscriptions feature to build a multi-plan subscription site with Stripe. This course requires a CraftQuest subscription.
Customize activation and other system emails
In addition to this Stack Exchange post on the topic, check out how this is done in the Workflow plugin in its Git repo.
Remove a Control Panel Section from a plugin
If you make a plugin and initially build it with a control panel section and later decide to remove it, getting rid of it might be a little trickier than you expect. Bookmark the post above for future-you.
Sponsor

Effortlessly build beautiful forms in minutes with Freeform!
Freeform is the most reliable, intuitive and powerful form building plugin for Craft. Everything is at your fingertips in our elegant form builder. It gives you full control to create simple or complex multi-page forms, as well as connect your forms to many popular API integrations. Templating is easy and highly customizable. Our ready-to-go templates and features like built-in AJAX and Conditional Rules Logic will have you ready in minutes! No other form plugin even comes close to comparing! You can trust Freeform (and the team behind it) to deliver the quality and support you expect and deserve.
Plugged In
Sprig: A reactive Twig component framework for Craft. ⭐️
Sprig is a free plugin for Craft CMS that allows you to create reactive components from Twig templates and/or PHP classes. These components, inspired by Live Wire can re-render themselves on user-triggered events (clicks, changes to input fields, form submissions, etc.) using AJAX requests, without requiring you to write a single line of JavaScript or using a framework.
This is cool.
Blitz Recommendations ⭐️
The Blitz Recommendations plugin adds a utility that provides templating performance recommendations for Craft CMS. While this plugin works seamlessly with the Blitz plugin, there is no dependency between them. In other words, this plugin can be installed and used for free with or without Blitz.
Elements Panel ⭐️
The Elements Panel plugin adds an Elements and an Eager-Loading panel to the debug toolbar for benchmarking your templates in Craft CMS.
Reasons
The Reasons plugin adds simple conditionals to field layouts – making it possible to hide or show fields on the fly, as the content is being edited.
Blocky
Utility plugin for Craft CMS to map Matrix fields. Blocky handles the logic of parsing your Matrix blocks so you can create cleaner Twig templates.
Yii, Twig, PHP & More
Twig Language 2 - Visual Studio Marketplace
Snippets, Syntax Highlighting, Hover, and Formatting for Twig for VS Code.
Overheard
It’s not Craft, but it’s interesting.
Pretty iTerm2 with a modern titlebar 💄💅
Matt Stein threw a little iTerm customization party on Discord last week. You can join in with these links.
- Make iTerm look more like Hyper
- ZSH with Powerelevel10k (which is way faster than Spaceship)
- One Dark Theme
- Fira Mono Powerline variant
- Matt’s custom icon for iTerm

GitLens — Git supercharged - Visual Studio Marketplace ⭐️
GitLens supercharges the Git capabilities built into Visual Studio Code. It helps you to visualize code authorship at a glance via Git blame annotations and code lens, seamlessly navigate and explore Git repositories, gain valuable insights via powerful comparison commands, and so much more.
Inline Parameters for VSCode
An extension for Visual Studio Code that adds inline parameter annotations when calling a function.
Deno Crash Course - YouTube
In this Deno crash course, we will talk about what Deno is and look at some of the basics as well as create a full REST API.
copyEmailLink.js
The link above will take you to a Git repo that just contains a function that will change the behavior of mailto
links on your site. Instead of the default behavior of opening an email app, it will copy the email address to the clipboard. You can see it in action in this Tweet.
ScrollTrigger - Plugins - GreenSock ⭐️
Scroll-driven animations re-invented.
In short, this is a first-party replacement for ScrollMagic. It’s got an easy-to-use syntax if you’re familiar with Greensock. Interested? Check out the Getting Started page.
devMode.fm // Amezmo cloud hosting and deployment for PHP
The guest on this episode is Ryan McCullagh, founder of the PHP hosting and deployment platform Amezmo, “the Netlify for PHP applications.”
CMS landscape through the years?
Ben Croker mentioned an Ecommerce Platform Growth graph over time and asked about a CMS platform version. It would be cool to see. Does anyone have some time and data on their hands?
BTW, I think this graph is from the Data Is Beautiful channel on YouTube. These might interest you also: