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.
If you didn't listen to the Last Lullabot Podcast last week, you may not be aware that Lullabot is shaking things up a bit on the podcast front. We're renaming the Lullabot podcast to the Drupalize.Me podcast. The Lullabot podcast has been running since January 2006, and we're reviving that legacy with a new bi-weekly podcast, talking about everything Drupal. Today is our first Drupalize.Me podcast, where we have a good chat about DrupalCon Munich with the Lullabot team: Drupalize.Me Podcast: Episode 1. Go check it out!
Upgrade Status: Phases 1 and 2 Complete
Blog postIt has been a few months since we started our site upgrade, and I wanted to give an update on our progress. We are a small team of three, who manage the site and create most of the videos, so needless to say we've gotten a bit waylaid on our schedule. We've also had quite a bit of fun distraction with our Lullabot company retreat (which was sooo fun!) and DrupalCon Munich (which was amazing). So, while we're not as far as we wanted to be, we have gotten a good chunk of work started, and we're through Phases 1 and 2!
We've been doing a lot of work with the Drupal Ladder, and we have two new FREE videos in the Drupal Ladder series. These cover the next two steps of the Ladder, testing and writing patches. Both lessons use a Drupal 8 sandbox site that has a known bug in it. First you walk through the process of testing a patch that someone else has provided, and in the next lesson you learn how to write that patch yourself. There is no crazy coding involved — the patch is changing some help text in Drupal core.
Write a Patch
FreeIn this video we will write our own patch to resolve an issue. We will take a screenshot of the issue before and after our patch, and upload the images and patch to the Drupal.org issue queue. This video follows the instructions in the Write a patch lesson on drupalladder.org.
Test Patches
FreeIn this video we will walk through the process of testing existing patches in the Drupal.org issue queue. We will read an issue, download and apply the patch with Git, and then test it to see if it works. This video follows the instructions on the Test patches lesson on learndrupal.org.
The lines that I have in my .bash_profile (shown at the end of this video) to add the Git branch to my command line prompt is:
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\h:\W \u\$(parse_git_branch)\$ "
I'm using a Mac, so your mileage may vary on other systems.
In this lesson we bring everything we have learned in this series and just round it out with some tips and tricks now that we have images in our content.
Additional resources
In this lesson we cover the Insert Module along with FileField Sources Module. The Insert Module is a great module when combined with a few others and is setup right. It takes a few configurations but gives you lots of flexibility with your images and placing them into the text area. We also demonstrate how you can use the FileField Sources module to make the insert module that much better when it comes to media management.
Note: not all Drupal modules provide access to images that are uploaded using a different toolkit. Before committing to a specific suite of media management modules, you should create a test site and practice uploading images. Based on your tests you will be able to better evaluate if you have chosen the right tools for your content managers.