Views arguments

The last type of responsibility a View field can have is to be used as an argument (or a contextual filter for Drupal veterans). In other words, configuring the View to be filterable by a parameter that is dynamically passed to it. Let's face it; most of the time, if we want to filter by a team, we won't rely on the actual string name as that can change. Instead, we tie everything to the record (by its ID). So that means we'll add the argument key to the team_id field of the players table (which also means that the query won't require a join so it will be more performant):

'argument' => array( 
  'id' => 'numeric', 
),  

In this case, we use the NumericArgument plugin which does pretty much all we need for our data type—it filters by what is expected to be a numerical data type. And we are finished with that as well. We can now dynamically filter our players view by the ID of the teams they belong to.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset