Date:
24 June 2024

The main focus for this month’s Melbourne Drupal Meetups was a presentation by Simon Lindsay. Simon shared insights on how he customised Drupal’s token filtering to enhance admin efficiency, and also gave a live demo.

Token tree filtering for better UX: presentation summary.

This presentation offered insights into token filtering in Drupal. Simon shared his journey of customising Drupal’s token filtering system to enhance the content management experience for admins.

The need for custom token filtering

Simon began by giving a brief overview of his history with Drupal, tracing back to his early days as a website developer. He explained how his work at Aussie AngelsExternal Link required him to create a more efficient and simplified content management system. Aussie Angels, initially a spreadsheet-based system, had transitioned to a no-code solution before finally adopting Drupal. The move to Drupal was driven by the need for a scalable and customisable solution that could keep pace with the rapid development needs of a startup.

The core issue Simon faced was the overwhelming number of tokens available in Drupal’s standard token browser, which presented too many options for internal admins. These admins needed to insert specific, relevant data into templates used for creating investment deals. However, the token browser’s default behaviour displayed an exhaustive list of tokens, many of which were irrelevant to their tasks. To solve this, Simon sought to filter the available tokens, allowing admins to access only the fields necessary for their work.

Developing a custom solution

Simon detailed the process of developing a custom token filtering system. He explained that, after failing to find an existing module that met his needs, he decided to modify Drupal’s token tree builder service. This service is responsible for generating the list of available tokens in the token browser. By altering this service, Simon was able to create a version that displayed only the tokens relevant to the tasks at hand.

He explained the technical steps involved, such as extending the service class and using specific parameters to filter tokens based on their names. For example, Simon implemented a system where tokens could be included or excluded based on simple string matching. This approach allowed for a highly flexible filtering system that could be easily adapted to different requirements.

Simon also highlighted some challenges he faced, such as ensuring backward compatibility and adhering to naming conventions that Drupal requires for service replacements. Despite these challenges, the solution was successfully implemented, significantly improving the usability of the token browser for Aussie Angels’ admin staff.

Live demo and practical insights

To demonstrate the effectiveness of his solution, Simon conducted a live demo during the meetup. He showed how the modified token browser worked, presenting a simplified interface that only displayed the necessary tokens. This reduction in options made it easier for admins to insert the correct data into their templates without being overwhelmed by irrelevant choices.

Simon also discussed the importance of practical considerations, such as performance and maintainability. While his code was not the most optimised, he emphasised that it was sufficient for the task since the token browser is not a frequently used feature. He also touched on the benefits of implementing the solution as a form alter or as a bundle class, offering flexibility in how the solution could be integrated into different projects.

Conclusion

Simon Lindsay’s presentation at the Melbourne Drupal Meetup provided valuable insights into customising Drupal to better meet the needs of specific user groups. By creating a more efficient token filtering system, Simon improved the content management experience for internal admins at Aussie Angels, demonstrating how thoughtful customisation can lead to significant usability improvements. His session served as an excellent example of how to tackle specific challenges within Drupal through targeted, practical solutions.