In this video we'll look at adding yet another field handler, but in this instance we will be adding a Views field that does not directly map to an actual field in the database. Instead we will be creating our own variation on some data and adding it as a field that can be used in our views — a field that shows the percentage of page views as a black bar graph.
Our new podcast, Drupalize.Me Podcast 3: The 3 W's of the Drupal 8 Initiatives - Who, What, and Why?, is a great overview of the new, cool stuff coming in Drupal 8.
Now that you’ve manually created a new variant for your front page, this lesson will teach you a much faster way to duplicate an existing variant. This technique is useful if your variants are very similar to one another.
Panels and the Page manager module allow you to create different versions of the same page (called variants) under different circumstances. In this lesson you will learn how to build two different versions of the content on your home page. People who are logged in to your site will see a different home page than people who are not.
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().