Now it’s time to make the site look less like Drupal and more like Mom and Pop, Inc. In this lesson we'll modify the core Bartik theme by changing the site logo and the color scheme to match what we need for our project.
Additional resources
This series will introduce you to the two most powerful features in Drupal: Fields and Views, fundamental building blocks when it comes to building Drupal sites. The Field module allows you to customize entry forms for entities, nodes and users, and comments. The Views module is the perfect counterpart to Field in that instead of putting content into your site through an entry form, Views allows you to get that content back out again in the way that you want.
In this lesson, we're going to be looking at building a job posting board for a university. We'll examine our case study and what it is that we need to do for this job posting board. Drupal core provides this site with a lot of good starting pieces, but we're also going to need to use some additional modules. We're going to focus on the core Field and Field UI and File field in order to create the custom forms that we need for the input for jobs and applications.
If you'd like to follow along with this series, you should install the Using Drupal Source Code and use the Chapter 3 Job Posting Board Installation Profile during the installation process,
Additional resources
The Field module provides an extremely flexible framework for creating forms to enter content. In past versions of Drupal, this was provided by a contributed module called the Content Construction Kit, or CCK, but this now a feature that comes with Drupal core itself. In this lesson we're going to get an overview of the Field module and the pieces it provides, including field types, input widgets, displays, view modes, and formatters. We'll also take a look at reusing existing fields and what that means.
Additional resources
To build this site, we’ll need to go beyond the default “Basic page” and “Article” content types offered by Drupal core. To get started with our job posting website, let’s think about the different content types needed to build all the functionality that we require. The site requires two different types: a Job Posting and a Job Application. In this lesson we'll map out our content type needs, and see what fields were going to use. Then we'll create the Job content type, making sure we add needed fields and set permissions so that it is working as expected.
Additional resources
The References module is a contributed module that allows you to create relationships between nodes and/or users. In this lesson we will take a look at the References project, explaining how References work, and then discuss some similar modules out there you may want to investigate.
Additional resources
Now we need to add a primary contact for the job position we've created. This will usually be the person creating the entry, but we’ll allow the user to enter any of the possible faculty members on the site. This will be done as a “User reference” field, provided by the contributed References module.
Additional resources
For usability, it’s often important to display forms and page contents in a specific order, and to add formatting so that it’s more clear what data is being presented. In this lesson we'll modify our Job content by reordering the fields, changing the field label display, and looking at how we can hide particular fields.
Additional resources
Now that the university is able to create job postings, it would be helpful if prospective employees could submit resumés to the positions in which they’re interested. In this lesson we will build out the Job Application content type. We will need to add another reference field, this time a node reference, to tie the applications to the correct job. To make it possible for applicants to submit their resumé we'll also need to add an upload field so that applicants can upload a document of specified file types.
Additional resources
The Views module provides listings of data on your site: users, comments, nodes, and more. Any listing of data provided by the Views module is called a view, and most Drupal websites today use Views in many different ways. In this lesson we'll get an overview of the Views module, including some specific concepts and terminology like Data Types and Displays, along with a tour of the major view settings and what they do.
Additional resources
The requirements of our site include two different main views. One view is a public-facing list, showing all the available jobs to users of the site. In this lesson we'll create our first view by enabling the modules we need, walking through the Views wizard to get our basic view in place, and then modifying various settings for our fields and working with contextual filters.
Additional resources
The Applications view will serve both as a tool for administrators and as a reference for users, with three different displays. In this lesson, we'll start to build the Applications view by creating the default display with our first listing, which is a master list of all the applications on the site. To pull in all of the information we're going to need, we'll begin working with Views relationships.
Additional resources
With our basic Applications view built, we have our default display. We also need another faculty display on the site. This second list will be largely the same as the default list, but it needs to show up as a tab on a job posting node, and only list the applications which relate to that particular job. We're going to need to create a new display, and override certain settings, plus add in a contextual filter, in order to get this view completed.
Additional resources
In this lesson we tackle the last display we need for our Applications view, by building a block for our applicants. This has us creating a new type of display, a block, as well as continuing to work with overrides. We also have to change the permissions on this particular display so regular users can see it, but at the same time we only want the view to show a user their own applications.
Additional resources
The basic job website that we’ve built only touches on the surface of the capability of Field and Views. There are a lot of possibilities for extending the functionality of this job site by adding more fields to both the Job and Job Application content types. In this lesson we'll review some other modules to explore:
- Automatic Node Titles
- Node Reference URL Widget
- Content Access
- Field Permissions
Additional resources
This lesson takes a look at working with the already existing entities in Drupal such as users and nodes and demonstrates some best practices for working with them in your own custom module. We'll focus on writing code that will work with any entity type and isn't hard coded to work with just nodes or just entities.
Additional notes:
There is a typo in the video. Joe created the variable $types = 'comment'; in one spot and then used it as entity_load($type, ... which obviously wouldn't work because the later is missing an 's' on the end. The downloadable code for this video doesn't have the typo.
Additional resources
This lesson demonstrates the bare minimum needed to create a custom entity type and to load an Entity from the database. We’ll look at implementing a minimum viable hook_entity_info, talk about the relationship between the Entity API and the Schema API and use entity_load to retrieve a single entity record from the database.
Note, although it would be considered best practices to name the entity with the name of the module, e.g. videoentity_video, we did not include the module name prefix here because it is tedious to type it all out and to say "videoentity_video" without confusing people.
In the next lesson we'll cover the various entity classes and how they work. However, if you just want to get straight to using your entity and doing things like $entity = entity_load();
you'll need to declare a controller for your new entity type. Simply add this 'controller class' => 'EntityAPIController'
in hook_entity_info()
. That will get you started, and well talk about what exactly that line does in the next lesson.
Note: the video doesn't mention the 'primary key'
element in the schema array (although it is in the code). This bit is necessary for the schema to install properly and work with the Entity API so if you're following a long make sure you add that part as well.
Additional resources
Before we can nicely publish our favorite bands’ photos on our website, we need to make sure to set up image styles, in order to create scaled-down versions of the images while leaving the original images intact. In this lesson we'll modify an existing image style to customize it, and also see how we can improve our image quality.
Additional resources
The Media module for Drupal 7 solves a number of long-standing media-related problems in Drupal. At its core, Media provides a framework to manage media assets on a Drupal site, regardless of whether those assets exist on the site’s server or somewhere else on the Internet. Media has had much active development over time, and was a moving target when Using Drupal was written, so the latest version of Media is a fair bit different from the version we cover in this lesson, "2.0-unstable3." Version 2 of Media is very, very different from version 1, which is a much older version. We highly recommend that you learn the fundamental pieces of Media 2.0 using the source code that comes with the book and is covered in the About the Using Drupal series. That will allow you to follow the lesson without getting lost in the changes. Then, when you upgrade to the latest version down the road, you will have a solid foundation to explore the newer versions.
Additional resources
To get our music reviews built, we need to get started with a new content type. In this lesson we will get the basics in place by creating the new content type, with our main fields, and the ability to upload an image.
Additional resources
Now that users can post reviews on the Band Wagon site, we need to make sure that the content they publish, including their intro photos, is actually displayed correctly. To accomplish that, in this lesson, we're going to configure the field display settings and apply image styles.