Wim Leers: XB week 4: annotated data model test

My Monday started with a pleasant surprise that is only possible in cross-timezone collaborations: Ted “tedbow” 1 had made a huge leap forward on #3450957: Prevent modules from being uninstalled if they provide field types used in an Experience Builder (XB) field, where he’s working on the first aspect where XB’s JSON blobs in the database must be queried.
Drupal 11 requires versions of databases that support JSON querying. Ted rather quickly discovered that JSON querying support is not consistent across different databases … but fortunately Brad “bradjones1 is working on #3343634 to add explicit JSON support to Drupal’s database abstraction layer, which is one of the endeavors sponsored by Pitch-Burgh! So: database nerds, unite!

(That means reviewing Brad’s work in that issue is yet another way of contributing to XB — in addition to helping Single Directory Components (SDC) move forward.)

To ensure we are aware of what works on which database from day one, I updated XB’s CI pipeline to run the test suite against MariaDB+MySQL+PostgreSQL+SQLite.

Missed a prior week? See all posts tagged Experience Builder.

Goal: make it possible to follow high-level progress by reading ~5 minutes/week. I hope this empowers more people to contribute when their unique skills can best be put to use!

For more detail, join the #experience-builder Slack channel. Check out the pinned items at the top!

Later on Monday, Ben “bnjmnm” and Jesse landed an MR that starts to connect the UI that you saw two weeks ago to the back end, and brought it alive: there’s now a tree view to provide a sense of place on the canvas, and much more:

Image removed. Try it yourself locally if you like, but there’s not much you can do yet.
Install the 0.x branch — the “Experience Builder PoC” toolbar item takes you there!

A day later, the first set of unit tests landed: those for StructuredDataPropExpressions (these express where to retrieve values mapped for SDC props).

On Thursday, Harumi “hooromoo”’s MR to provide the foundations for undo/redo support landed, after the most enthusiastic approval I think I’ve ever seen Lee “larowlan” give! :D

That same day, his colleague Griffyn “griffynh” ran the second asynchronous XB meeting in Drupal Slack (archive on d.o: #3453097), this time with 21 participants of the ~250 people in the #experience-builder channel (~100 more compared to 2 weeks ago).
The most heavily debated topics were the data model/persistence layer and Cypress vs vitest for tests.

By Friday, I managed to finish up the work that I already shared a video of a week prior (see week 3), where a PropSource (which itself uses a PropExpression) can be chosen for each component prop and edited using Drupal’s existing Field Widgets. Crucially, it now includes a fully annotated end-to-end test that verifies the demo in detail:

  • an article using an XB field can be created
  • expected data is stored for the XB field, with a handful of placed components, and all prop source types: static, dynamic and adapter
  • each of these prop sources can be evaluated/resolved to a concrete value to pass into the corresponding SDC prop
  • each of the placed components renders into the expected HTML

In other words: it’s making the concrete implementation of #3440578: JSON-based data storage proposal for component-based page building tangible and debuggable in a way that required reading dozens of files previously! 2

Thanks to Ted & Lauri for reviewing this!

  1. Forever infamous for his shining sunglasses moment on stage during DrupalCon Pittsburgh — captured it in exquisite detail by Mike “mherchel”! ↩︎

  2. Hence it’ll serve as a canary for the data model/storage back-end infrastructure in the short–medium term. ↩︎

Palantir: From Finance to Palantir

Image removed.

Taking a dive into the deep, dark quagmire of life

Some people have career aspirations from a young age, but for the rest of us, discovering a career-worthy passion, or even learning how to distinguish a job from a career, can take some time. I was nearly ten years into a job in finance (managing insurance/retirement/wealth-building products) when I finally admitted to myself that I couldn’t do it anymore. I felt like I should have a career, not just a job. I wanted to feel proud of the way I spent my days.

Diving in

After some soul-searching, I signed up for a Full-Stack Web Development bootcamp. I was never the kid who tinkered with code or tried to see how my AOL Instant Messenger worked (yes, I was a kid of the 90s) - but I suddenly found myself fascinated with the combination of language, math, and puzzle that was hiding in my browser’s Inspect tool. The bootcamp’s cost made this a risky prospect, but it also made me more likely to commit fully. I can’t say I loved every moment of the grind; working full-time, raising three kids (whom I had adopted just two days into the bootcamp), attending evening classes, keeping up with homework, and maintaining sanity was not always the easiest, but I tend to thrive in chaos. I learned the MERN Stack (MongoDB, Express.js, React, and Node), and after six months I left the bootcamp with one of the highest scores in my class and even higher hopes.

Image removed.Cue the mass tech layoffs of late 2022, pitting my emerging knowledge against developers with years of experience at tech giants such as the site formerly known as Twitter. My understanding of code was evident, but my ability to explain code was underdeveloped, leaving me flailing in interviews and unable to find anyone willing to take a chance on me. Anyone, that is, until my local Women Who Code chapter posted about Palantir.net’s fellowship program. I applied, spent three months learning Drupal through DrupalEasy's Drupal Career Online program, and started an internship with Palantir.net. That internship turned into a full-time engineering role, and now I’m creating innovative tech and building professional websites from scratch.

Going deep

How could I transition from finance to React/JavaScript to Drupal/PHP in such a short time? Same way I managed to learn French — its proximity to English based on its Latin roots gave me a leg up. Both JavaScript and PHP are Object-Oriented languages, meaning they derive from making real-world objects into code. Object-Oriented Programming, or OOP, is a paradigm that encompasses several coding languages, and since I already had a base in OOP via JavaScript, I mainly needed to learn the syntax of PHP as the concepts were mostly the same. Not only are the languages similar, but the overall folder structure and architecture of both Drupal and React can be set up using the same patterns. I quickly noticed my new Palantiri teammates using the MVC (Model-View-Controller) architecture, which I was already comfortable with.

Another benefit of that MVC architecture is its collaborative nature. By separating sections of the code based on functionality, different people could work simultaneously on building one piece of a site without risking overwriting one another. React most prominently offers collaboration through its separation of interests via Components, delivering an end product to users, while Drupal is set up to not only be collaboratively built, but to allow site builders to delegate content creation, and even site administration, to users.

Surfacing from murky depths

Perhaps the coolest thing I discovered through this journey is the ability to create a site harnessing the powers of both Drupal and React! Drupal’s Content Management System structure creates a powerful backend for React’s simple and extensive front-end library. This just leaves me with the accessibility question - how can we make Drupal a more popular and attainable technology for entry-level developers? According to Statista’s data analytic survey, Drupal ranks 29th among the most-used frameworks among developers worldwide as of 2023. In the same survey, React ranked second only to Node, which is another JavaScript framework.

I think we can find a path for learners of all types, we just need to harness the power of our community to get there. We are not in competition with React or Wordpress or any other framework, Drupal is just another tool that people should have an opportunity to explore at any level. Who knows? Maybe they’ll fall in love like so many others have.

Calm waters

I love the glimmer of awe in people’s eyes now when I tell them I’m a software engineer. I can’t say the path was easy, but I’ve never regretted making the career change, and I never tire of continuing to suck up every ounce of knowledge I can find. I love the curiosity and creativity that I can bring to work with me every day, bouncing from front-end to back-end work, developing brand new technologies, and exploring every little thing that interests me. I’m happy to say I have found my career. 

Culture Drupal People

Golems GABB: 2024 Trends: What's New for Drupal

2024 Trends: What's New for Drupal Editor Wed, 06/12/2024 - 16:00

People always want to predict the future. They say that is not good, but this doesn't apply to the Drupal 2024 trends. Undoubtedly, Generative Artificial Intelligence will shape tech trends and stimulate further progress in the website development industry.
However, there are other matters worth paying attention to. Mintz, World Wildlife Fund, Chupa Chups, Mattel, and other prominent Drupal websites won’t sit idly by viewing this chaos of innovations and advancements.
Now is the time for unique insights with Golems web development agency about what Drupal 2024 will be like. The more aware you are of prospective game-changing rules, the more up in arms you will act in SEO, marketing, and business growth strategies. Stay tuned to take a sneak peek into the future!

The Drop Times: Why 1xINTERNET Rushed to Support the Starshot Initiative: Insights from Baddý Sonja

Discover why 1xINTERNET swiftly supported the Drupal Starshot Initiative. In this interview by Kazima Abbas, Baddy Sonja Breidert, CEO and Co-Founder, shares the motivations, goals, and impact behind their involvement. Don't miss these valuable insights from a key player in the Drupal community!

The Drop Times: Drupal Starshot Initiative Sets Strategic Milestones in Product Definition

The Drupal community advanced its Starshot initiative with a key session on June 7, 2024, led by Dries Buytaert and Cristina Chumillas. The session focused on refining the Drupal ecosystem with user-centric improvements and strategic development milestones. Key topics included the mission statement review, concept wireframes, draft milestones for DrupalCon Barcelona, and the Starshot Council.

Dries Buytaert: Major version upgrades in Drupal: tools and workflow

When a new major version of Drupal is released, custom code often requires updates to align with API changes, including the removal of deprecated APIs.

Because I keep forgetting certain aspects of this workflow, I decided to document it for future reference.

Tools overview

Tool Interface Functionality Target Audience Upgrade Status module UI in Drupal Identifies deprecated code, hosting environment compatibility, and more Site administrators and developers Drupal Check Command-line Identifies deprecated code Developers, especially during coding and continuous integration (CI)

Upgrade Status module

The Upgrade Status module assesses a Drupal site's readiness for major version upgrades by checking for deprecated code and other compatibility issues.

Image removed.Screenshot of a Drupal upgrade status report showing hosting environment compatibility checks.
  1. Install the Upgrade Status module like you would install any other Drupal module:

    [code bash]$ ddev composer require –dev drupal/upgrade_status[/code]

    Here, ddev is the tool I prefer for managing my local development environment. composer is a dependency manager for PHP, commonly used to install Drupal modules. The –dev option specifies that the module should be installed as a development requirement, meaning it is necessary for development environments but not installed on production environments.

  2. Enable the Upgrade Status module:

    [code bash]$ ddev drush pm-enable upgrade_status[/code]

    drush stands for "Drupal shell" and is a command-line utility for managing Drupal sites. The command pm:enable (where pm stands for "package manager") is used to enable a module in Drupal.

  3. After enabling the module, you can access its features by navigating to the Admin > Reports > Upgrade status page at /admin/reports/upgrade-status.

Upgrading PHP and MySQL using DDEV

The Upgrade Status module might recommend updating PHP and MySQL, per Drupal's system requirements.

To update the PHP version of DDEV, use the following command:

[code bash]$ ddev config –-php-version 8.3[/code]

To upgrade the MySQL version of DDEV and migrate your database content, use the following command:

[code bash]$ ddev debug migrate-database mariadb:10.11[/code]

After updating these settings, I restart DDEV and run my PHPUnit tests. Although these tests are integrated into my CI/CD workflow, I also run them locally on my development machine using DDEV for immediate feedback.

Drupal Check

Drupal Check is a command-line tool that scans Drupal projects for deprecated code and compatibility issues.

Image removed.Output of Drupal Check command indicating no deprecated code was found.
  1. Installation:

    [code bash]$ ddev composer require –dev mglaman/drupal-check[/code]
  2. Run Drupal Check from the root of your Drupal installation:

    [code bash]$ ./vendor/bin/drupal-check –memory-limit 500M docroot/modules/custom[/code]

    I usually have to increase the memory limit, hence the --memory-limit 500M.

Specbee: Why and How to migrate your DotNetNuke (DNN) site to Drupal 10

First things first, let's talk about why you're here. You've got a DNN website that's starting to show its age, and you're eyeing that sleek, modern Drupal CMS like it's the latest iPhone. From DotNetNuke to DNN Platform to DNN Evoq-sometimes simply called Evoq-this CMS has seen a series of transformations. Once an extremely popular CMS solution for organizations (mostly enterprise-level), DNN Evoq has faced the inevitable challenge of staying relevant over two decades. It's hard for any software to remain popular for over 20 years, especially with the changing world of web development and content management. Drupal, despite being older than DNN (okay, a year older), is thriving! Over time, it has only evolved into a more modern, user-friendly, and robust CMS. Moreover, Drupal excels at what it was designed to do: effective content management.  However, this is not intended to be a comparison blog of DNN vs. Drupal, even though we'll touch on a few reasons to consider the switch. This article aims to shed light on the DNN to Drupal migration process and what it entails. Additionally, we will share a case study of one of  Specbee's successful DNN to Drupal migrations.  Why you should migrate from DNN Evoq to Drupal To those who need to know some history of DNN, it was created by Shaun Walker and launched in late 2002. Written in C#, DNN is open source and relies on .NET framework and ASP.NET Web Forms. DNN soon became a platform known for its extensibility and seamless scalability which also brought in a lot of consultants and agencies to offer DNN development services.  However, over the years, DNN has experienced significant changes. The shift to the ASP.NET MVC model in 2009, coupled with some acquisitions, led to a decline in its user base and community support. DNN started relying on outdated technologies (since the .NET framework stopped development in 2019) and is unable to adapt to modern technologies and advancements. This evolution made it less appealing for businesses looking for a robust and active platform.  Now, why should you consider moving to Drupal, especially Drupal 10? Active and Vibrant Community: Drupal has one of the largest open-source communities. This means continuous improvements, a wealth of modules and themes, and a support system that's always buzzing. Continuous innovation: Drupal's constant innovation, driven by its passionate community, keeps it ahead with advanced features and enhancements. New strategic initiatives like Drupal Starshot, Project Browser, Experience Builder, Recipes, and Automatic Updates are poised to revolutionize the Drupal experience, making it more intuitive, efficient, and adaptable than ever before.  Cutting-Edge Features: Drupal 10 comes packed with modern features. It leverages Symfony 6 and Twig 3, ensuring your site is not just robust but also future-proof. The new admin theme, Claro, and the front-end theme, Olivero, offer a more intuitive and visually appealing experience. Effective editorial workflow system: With Drupal, end users can easily create and manage workflows tailored to their organization's needs and adjust them on-demand as necessary which is becoming more and more of a demand today.  In comparison, DNN's customization options and support for complex editorial workflows often require extensive coding knowledge.  Scalability and Flexibility: Like DNN, Drupal is known for its scalability. However, Drupal takes it a step further with its flexible content architecture, allowing you to create and manage various content types with ease. Security: Drupal is renowned for its strong security track record. The Drupal Security Team actively monitors and addresses vulnerabilities, giving you peace of mind. SEO and Performance: Drupal 10 includes out-of-the-box features that help improve SEO and site performance. From clean URLs to advanced caching mechanisms, it’s designed to help your site rank better and load faster. Accessibility: Drupal is committed to web accessibility standards, ensuring your site is usable by everyone. Extensive Ecosystem: With thousands of modules and themes, Drupal offers a vast ecosystem to extend your site's functionality without reinventing the wheel. By switching to Drupal 10, you're stepping into a future-ready, secure, and highly customizable environment. It's a move that can significantly improve your digital presence and provide a solid foundation for growth. Preparing for the migration Before you begin your DNN to Drupal migration, we recommend reading this article to get yourself prepped for a migration regardless of the version. It covers what information you should share with your Drupal development partner. This migration is also a perfect time to add those extra features or third-party integrations you've always wanted. Additionally, it's a great opportunity to revamp your website's design and user experience if needed. Consider your website’s current SEO positioning and how you would like to optimize it. Once you've considered everything, create a backup of your website to avoid any accidental changes or data loss. Next, make a checklist of your content structure, including content types, URLs, metadata, and media files. After this, let the Drupal migration experts take over. DNN to Drupal migration process Here’s a 4-step migration process that is (or should ideally be) followed by your Drupal migration partner: 1. Migration Audit Identify your DNN website features, functionality, modules, and content structure Conduct a detailed analysis to understand the digital landscape Catalog content views for easier replication Develop a strategic content migration strategy 2. Build Application Meticulously rebuild content structure and theme Replicate website features, add new features Conduct thorough regression testing Ensure a solid foundation, seamless functionality, and flawless performance 3. Migrate Content Content extraction from your database in a CSV, XML or JSON format Ensure a seamless transition from DNN to the latest Drupal version Import all contents and valuable assets, match them with the freshly created content types and fields Meticulously validate the entire data migration process for data accuracy and completeness. 4. Testing Thoroughly test migrated data for sanity and integrity. Subject replicated features to smoke testing and load testing. Guarantee seamless performance under various scenarios. Conduct meticulous security checks. Watch this video of our step-by-step Drupal migration process, irrespective of the CMS you are coming from. (To be embedded) https://youtu.be/D5JUud_a81k?feature=shared A DNN to Drupal migration case study The client (Stamats) approached us with a two-fold issue. They had three magazine sites on a legacy version of DNN that was riddled with malware and needed major work for the migration to Drupal. Among those sites was MeetingsToday.com.  Meetings Today was several years old, and had more than 20,000 articles in DNN. There was also extensive functionality related to their physical magazine, events, podcasts, webinars, and more. Their primary goal was to retain and grow their audience. They were experiencing issues with editing, and an uncertain future. The challenge came to Specbee to create a Drupal distribution that could serve the core publishing needs of several online magazine sites built in DNN.  So we built a custom Drupal distribution to save them time and money in the long term. This approach allowed any new feature developed for one site to be easily implemented across all sites while preserving their unique designs. It also gave them the ability to spin up a new publishing site without building a brand new website from scratch getting them to market 10x faster.  Specbee delivered a solution that allowed for Drupal's powerful editorial controls and publishing tools for multiple sites while allowing those sites to retain their unique functionality. References https://devessence.com/blog/!/22/what-is-your-dnn-migration-strategy/https://www.dnnsoftware.com/community-blog/cid/134716/asp-net-mvc-and-d…https://www.linkedin.com/in/shaunbrucewalker/ Final thoughts We understand that migrations are never an easy decision for any business. While entrusting a reliable technology partner can alleviate some concerns, it's crucial to dedicate your attention and time before handing over the reins. By choosing the right Drupal partner (such as Specbee, a certified Drupal migration partner), you can streamline the migration process, making it as seamless and painless as possible. Still wondering if you should migrate your DNN website to Drupal? Give us a call and we’ll help you make the right decision.

PreviousNext: Filtering and sorting search results by date range with OpenSearch

How to make use of OpenSearch (and Elasticsearch) built-in data-types specifically designed for filtering and sorting date ranges.


 

by lee.rowlands / 5 June 2024

It's fairly common to have content with a date range. E.g., events or content that is only applicable for a given date.

Sorting and filtering results by date can be complicated, especially if you have to support features such as multiple date ranges and optional end dates.

But OpenSearch (and Elasticsearch) have data types specifically designed for this use case.

The key here is to index your data using a Range field type.

Let's consider an example we recently built for NSW.gov.au. The requirements for the field were as follows:

  • Index a grant content-type
  • The grant content-type has a date-range field
  • The field has optional end dates via the Optional End Date module
  • The field is multi value
  • There is also a boolean 'Grant is ongoing' field that flags the grant as 'Evergreen'

The filtering requirements include a 'Status' field, which has options for:

  • Open - the current date must fall inside one of the date-range values
  • Closed - the current date is after date-range values
  • Opening soon - the current date falls inside a future date range

Additionally, the search results should be sorted in the following order when no keywords exist:

  • Open
  • Opening soon
  • Closed

Defining a date range field in Drupal/Search API

The first step is to inform Search API about the date-range data type. How you do this will depend on whether you're using Elasticsearch connector or Search API OpenSearch.

If you're using Search API OpenSearch, the good news is that it is already supported in the 2.x branch.

If you're using Elasticsearch connector, you should implement hook_elasticsearch_connector_supported_data_types_alter and add date range as a data-type - something like this

/**  * Implements hook_elasticsearch_connector_supported_data_types_alter().  */ function YOURMODULE_elasticsearch_connector_supported_data_types_alter(array &$data_types) {   if (!in_array('date_range', $data_types)) {     $data_types[] = 'date_range';   } }

If you're using Elasticsearch connector, you also need a processor plugin to put the field values into the index. You can take inspiration from how Search API OpenSearch achieves this.

Indexing Drupal data

Once you have those pieces in place, you simply need to configure your date field to use the Date Range data type in the Search API index.

Constructing the queries

With the data in your index, the only thing left is to construct your queries to make use of the date range data-type.

In these examples, we'll assume your date-range field is called 'application_dates', that the field is multi-value and that the end date is optional.

We will use 1710201396000 as the current timestamp (in epoch microseconds).

Filtering to 'open'

This one is the simplest. You need a new term query that uses the current date

{   "from": 0,   "size": 10,   "query": {     "bool": {       "must": [         {           "term": {             "application_dates": 1710201396000           }         }       ]     }   } }

For a date-range field, the use of a term query will match any document where the given value is between the start and end of the range.

Filtering to 'closed'

This one is a bit more involved. We need to combine some conditions

{   "from": 0,   "size": 10,   "query": {     "bool": {       "minimum_should_match": 1,       "should": {         "bool": {           "minimum_should_match": 1,           "must_not": [             {               "range": {                 "application_dates": {                   "gte": 1710201396000                 }               }             },             {               "term": {                 "grant_is_ongoing": true               }             }           ],           "should": [             {               "range": {                 "application_dates": {                   "relation": "WITHIN",                   "lte": 1710201396000                 }               }             }           ]         }       }     }   } }

First, we have a should, which is an OR query in OpenSearch parlance. We're saying the grant must not have any future open dates (gte: 1710201396000) AND must not be flagged as ongoing. Then we're saying all of the application dates should be in the past (lte: 1710201396000).

Filtering to 'opening soon'

Here again, we need multiple conditions.

{   "from": 0,   "size": 10,   "query": {     "bool": {       "must": {         "range": {           "application_dates": {             "relation": "WITHIN",             "gte": 1710201396000           }         }       },       "must_not": [         {           "term": {             "application_dates": 1710201396000           }         },         {           "term": {             "grant_is_ongoing": true           }         }       ]     }   } }

First, we are saying there must be at least one date where the date range is in the future (gte: 1710201396000) and that the grant must not be ongoing OR have any date ranges that match the current date (term: 1710201396000) (i.e. are open).

Sorting

Sorting is a little more complex. We can make use of filters in our sort expressions.

To do this, we also need to index our date-range as an object so we can use nesting.

We duplicate the application_dates field to an application_dates_sort field and make this use the nested data-type. The mapping will look like this

{   "application_dates_sort": {     "type": "nested",     "properties": {       "gte": {         "type": "long"       },       "lte": {         "type": "long"       }     }   } }

Then, we can make use of this in our sort expressions. E.g. to have open items appear first, we can use

{   "from": 0,   "sort": [     {       "application_dates_sort.lte": {         "order": "asc",         "mode": "min",         "nested": {           "path": "application_dates_sort",           "filter": {             "bool": {               "must": [                 {                   "range": {                     "application_dates_sort.lte": {                       "gte": 1710201396000                     }                   }                 },                 {                   "range": {                     "application_dates_sort.gte": {                       "lte": 1710201396000                     }                   }                 }               ]             }           }         },         "missing": "_last"       }     }   ],   "size": 10 }

What we're doing here is sorting by the opening date, ascending, but using a filter to only match on records where the current date falls between the start/end date. We're telling OpenSearch to put any objects that don't match (missing) at the end.

We can stack sort expressions like this — subsequent expressions will apply to those that were 'missing' from the first sort. Combining these lets us achieve the desired sort order of opening -> opening soon -> closed.

Wrapping up

OpenSearch is pretty powerful. But to make the most of its features, you need to ensure your data is mapped into the right data-type. Using date-range fields for storing date-ranges takes a little bit of extra planning, but it leads to much more efficient queries and a better experience for your users.

Tagged

OpenSearch