This video continues the process of adding a custom field handler started in the previous chapter.
Additional resources
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.
Additional resources
In this video Joe describes the process of adding the rest of the fields from the databasics module to our implementation of hook_views_data() including how to differentiate between different data types like strings of text and numeric values and how this changes the views module's behavior. Then Joe talks about how to tell views about various tables that can be used in relationship to the databasics table via foreign keys like the node ID.
Additional resources
Modules Needed
This week we're happy to continue two series for you. Coding for Views series continues to dive into fields and handlers, while the FREE Building Websites Using Panels series looks at using variants.
Coding for Views
Last weekend we had a bit of a kerfuffle with one of our video streaming servers which affected those of you on, or connecting to our servers on, the US west coast. And unfortunately it took a bit longer for us to notice than it should have. We're sorry about that and we learned a lot in the process. Now that we've had a chance to fix the problem, understand why it happened, and have a plan for preventing it in the future here's a brief explanation.
This week we are launching a great new series by Jen Lampton, "Building Websites Using the Panels Module," in addition to continuing our Coding for Views series. The Panels module which has been a long requested video series from our members and we are proud to kick that off with this introductory set of videos.
Jen covers everything from the Panels interface to using variants for multi-scenario layouts. She'll cover creating multi-column pages and how the Page Manager module, part of CTools, with Panels gives us a much more flexible layout engine than Drupal alone. This will lay a great foundation for a future, advanced series on how to use code with Panels to really get crazy.
Each piece of content placed into a panel has it’s own configuration settings, covering everything from display style to access control. In this lesson we will take a tour through the settings for each pane.
Drupal would like to assume that every page on your website will use the same layout. As it turns out, this is often not the case. The home page of your site, in particular, regularly uses a different layout. In this lesson we will demonstrate how you can use Panels to build a unique home page layout for your site.
Additional resources
In this first series of Panels videos on Drupalize.me you will learn how to use the Panels module to take your Drupal website to the next level. When you reach the limits of what Drupal alone allows you to do with its layouts, adding Panels to your site enables you to create more sophisticated displays of your content. Here are just a few things the Panels module makes easy:
- Divide the display of your content into multiple columns
- Place blocks into the center of your pages
- Use different layouts on the same page, under different circumstances
Because Panels works with the Page Manager module in ctools, you get all the benefits of the page manager, as well as complex control of your layouts. Page manager allows you to take over many of the ‘default’ displays in Drupal, including the display of content (nodes), profiles (users), category listings (taxonomy), and also the edit forms for each of these entities.
Additional resources
In this video Joe looks at using hook_views_data()
in order to describe a database table to views such that views is capable of making queries to that table. We’ll talk about describing the table itself, and how to get it to appear in the views UI as an option that can be used as a base table.
Additional resources
Modules Needed
In this video Joe continues the discussion of using hook_views_data()
to describe a module's table to the views module. Building on what was covered in the previous chapter we now deal with exposing one of the individual columns from our table as a field that views can use for filters, sorts, and to display.
Additional resources
Modules Needed
Drupalize.Me Podcast 2 with Jen Lampton
Blog postWe're happy to present episode 2 of the Drupalize.Me podcast. In this podcast, Addi interviews Jen Lampton, who is a long-time Drupal contributor.
Today we're happy to start our dive into the Coding for Views series. Last week we kicked off the series by getting things all set up on our demo site and covering the resources we have available. This week we create a simple module that uses the Views API to export our site's view and store it in code in our module as a default view. With that basic understanding in place, we take a look at an existing module, our Databasics module, that we would like to integrate with Views, so we can dive even deeper in next weeks videos.
In this chapter Joe will take a look at where to get a copy of the databasics code and what it does already. Throughout the rest of this series we will be working towards replacing functionality from the databasics modules with views integration in order to allow for greater flexibility in the ways that our module can be used. We'll talk about each of this pieces of functionality in this chapter.
Additional resources
Databasics module on GitHub
Overview of the Database Layer in Drupal 7
One of the most common things to do with Views is export a view from your site and store it in code as a default View. This is what Features module does when you create a feature with a view in it. In this lesson we'll export our sample site's view and add it to our module with hook_views_default_views().
To get things started, in this lesson we'll create a new module, and use hook_views_api() to let Views know we want to use its API.
There's a reason views is the most popular module on drupal.org and it's pointy-clickly user interface is only a part of that. In this series we cover the ins and outs of writing modules that implement the Views API. Once you’ve realized the power of creating complex lists of nodes, users and other content via the views UI the next logical desire is to allow people to do that with the content provided by your custom module as well. This series will take an in-depth look at exposing your own database tables to the Views module so that users can use them as a place to pull content from including the fields themselves and meta-data about how they can be used to create relationships to other content on your site.
After getting the basics out of the way we’ll also take a look at writing our own custom field handlers to expose our module’s data to views so that it can be sorted, filtered, and queried in new ways. We’ll also look at implementing views plugins to do things like add custom access control options to views and to add new output styles.
Once you understand a bit more about how views works under the hood and how easy it is to tie in to that system you’ll be reimaging your solutions for all sorts of different problems.
In this lesson, we give a brief overview of utilizing a very important feature when it comes to working with Drupal and that's Drupal.org. We show you how to get to the Views API documentation that is now part of Drupal's API documentation and teach you how to use the search function for finding particular function.
Additional resources
New Series: Coding for Views
Blog postViews is without a doubt the most popular module on drupal.org, and one of the reasons for it’s popularity is the plethora of modules that enhance the out of the box views experience. These modules add new display options like a calendar or Javascript caoursel, new formatters for existing fields, and even new backends so you can query things other than MySQL. Like Drupal itself views is written to be extended and it’s not uncommon to need to do just that in order to meet your site specific requirements.