Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Writing Custom Field Handlers

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:03
    [with Joe Shindelar]
  • 0:04
    Now that we've seen how we can expose our table
  • 0:07
    and the various columns on our databasics table to the Views module,
  • 0:11
    the next thing we're going to want to do is write our own custom handlers for our fields.
  • 0:16
    Writing a custom handler is a process of overriding one of the default handlers
  • 0:20
    that Views provides by extending that base class.
  • 0:24
    We're going to use object inheritance here in order to make use of the code
  • 0:27
    that Views already provides us and override just the pieces that we need to
  • 0:31
    in order to get some new functionality.
  • 0:34
    We do this when we've got information contained within a column on our table
  • 0:03
    [Com Joe Shindelar]
  • 0:04
    Agora que vimos como podemos expor nossa tabela
  • 0:07
    e as várias colunas na nossa tabela databasics ao módulo Views
  • 0:11
    a próxima coisa que iremos querer fazer é escrever nossos próprios handlers customizados para nossos fields.
  • 0:16
    Escrever um handler customizado é um processo de sobrescrição dos handlers padrões
  • 0:20
    que Views fornece, através da extensão daquela classe base.
  • 0:24
    Iremos usar herança de objeto aqui para utilizar o código
  • 0:27
    que Views já nos fornece e sobrescrever apenas as partes que precisamos
  • 0:31
    para podermos ter uma funcionalidade nova.
  • 0:34
    Fazemos isso quando temos informações contidas dentro de uma coluna na nossa tabela

Writing Custom Field Handlers

Loading...

In this video Joe will walk through writing a custom field handler for views. Demonstrating how to extend the set of handlers that come with the views module in order to provide new functionality or for dealing with new types of data. In this case we'll look at how to treat the numerical values in the databasics module as percentages in views. The method used to write a field handler in this video is similar to overriding other handlers like filters and sorts that will be discussed in coming chapters and provides some important foundations for understanding how to work with all views handlers.

Downloads: 
Log in or sign up to download companion files.
Additional resources: