Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Drupal 10 Module Development
  • Table Of Contents Toc
  • Feedback & Rating feedback
Drupal 10 Module Development

Drupal 10 Module Development

By : Sipos
4.7 (10)
close
close
Drupal 10 Module Development

Drupal 10 Module Development

4.7 (10)
By: Sipos

Overview of this book

Embark on a journey of Drupal module development with the latest edition of this must-have guide written by Daniel Sipos – a Drupal community member! This fourth edition is meticulously revised to cover the latest Drupal 10 enhancements that will help you build custom Drupal modules with an understanding of code deprecations, changing architecture, data modeling, multilingual ecosystem, and so on. You’ll begin with understanding the core components of Drupal 10 architecture, discovering its subsystems and unlocking the secrets of creating your first Drupal module. Further, you'll delve into Drupal logging and mailing systems, creating theme hooks, and rendering a layout. As you progress, you'll work with different types of data storage, custom entities, field types, and work with Database APIs for lower-level database queries. You'll learn to reap the power of JavaScript and ensure that your code works seamlessly on multilingual sites. You'll also learn to create custom views, automate tests for your functionalities, and write secure code for your Drupal apps. By the end of this book, you'll have gained confidence in developing complex modules that can solve even the most complex business problems and might even become a valuable contributor to the Drupal community!
Table of Contents (21 chapters)
close
close
3
Chapter 3: Logging and Mailing

Custom Views filter

In a previous section, we exposed our players and teams tables to Views, as well as made the team name a possible string filter to limit the resulting players by team. But this was not the best way we could have accomplished this because site builders may not necessarily know all the teams that are in the database, nor their exact names. So, we can create our own ViewsFilter to turn it into a selection of teams the user can choose from. Kind of like a taxonomy term filter. So, let’s see how it’s done.

First, we need to alter our data definition for the team name field to change the plugin ID that will be used for the filtering (inside hook_views_data()):

'filter' => [
  'id' => 'team_filter',
],

Now we just have to create that plugin. And naturally, it goes in the Plugin/views/filter namespace of our module:

namespace Drupal\sports\Plugin\views\filter;
use Drupal\Core\Database\Connection;
use...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY