We need to add our own audio player to make the audio experience nice and slick on the site so people don't have to download the files to listen to them. In this lesson we'll install the jPlayer module and the jPlayer library, then make sure our configuration is set the way we want.
Note: This series is covering Media Module version 1.x. To learn about Media Module 2.x, check out our Using Drupal Chapter 4: Media Management series.
Additional resources
Mapping with Leaflet
CourseBefore we can display a location on a map, we need to decide on a location storage method. This is a critical step because not all storage methods are compatible with every mapping module. Since we'll be using Leaflet, we'll need to use Geofield to store our geographic data. Geofield will provide us with a new type of field that we can add to any entity bundle or content type. Geofield provides many different field formatters that can display geographic data in a variety of formats, such as latitude and longitude or well known text.
By the end of this lesson, you should be able to:
- Download and install Geofield and its dependencies GeoPHP and CTools
- Create a field on a content type using Geofield
- Enter a latitude and longitude for a location node
Join Amber Matz as she walks you through how to prep your site to store location data using Geofield module.
Additional resources
Geographic information is used to find a location, get directions, or check on traffic – and so much more. In the Drupal mapping world, solutions range broadly.
Leaflet is one solution that works for many situations. In this series, you'll get up and running with mapping using Leaflet. We’ll add and configure field types, install Leaflet, and create and customize maps. When you complete this series, you'll be able to create a map of both single and multiple points, geocode address data, configure geofield to store geographic data, and customize the look and feel of your Leaflet maps interface.
Now that we've stored the latitude and longitude for a node, we can display it on a map. In this lesson, we'll take a look at the documentation for Leaflet and we'll download and install the Leaflet JavaScript library and the Leaflet Drupal module, which loads the Leaflet JavaScript library and provides configuration options that we'll use later on.
By the end of this lesson, you should be able to:
- Install Leaflet and its dependencies to your Drupal site
- Configure a Geofield field to display as a Leaflet map
Additional resources
Manually entering a latitude and longitude for each node is a tedious process. Just finding out what those numbers are for a given location less than ideal. One of the most common ways to communicate a location to another person is by using a postal address. How many times do you enter a latitude and longitude into your favorite mapping app to get directions? Hardly ever, right? Most of the time you would just enter the street address and the app "just knows" how to find it. In this lesson, we'll configure our Drupal site to Geocode a postal address into geographic data that our Leaflet map can display.
Additional resources
n the previous lesson, we configured the location content type to collect address data using Address Field module. Then we brought in Geocoder module and configured the Geofield on our location content type to use the data from the Address Field. With Geocoder all set to transform that address data, we are now ready to create some new location nodes. Since the process of geocoding addresses happens behind the scenes when a new node is created or when a node is edited and saved, it was important to do this configuration first, before creating any more location nodes. To expedite data-entry, in this lesson, I'll walk through the process of importing a comma separated value text file or CSV file into a Drupal site with Address Field using Feeds.
By the end of this lesson, you'll understand what data you need to be sure and include in your CSV to avoid trouble with Address Field, how to configure a feeds importer, and how to configure the field mapping in the importer with the somewhat esoteric field names that Address Field provides.
Additional resources
Before we can display a location on a map, we need to decide on a location storage method. This is a critical step because not all storage methods are compatible with every mapping module. Since we'll be using Leaflet, we'll need to use Geofield to store our geographic data. Geofield will provide us with a new type of field that we can add to any entity bundle or content type. Geofield provides many different field formatters that can display geographic data in a variety of formats, such as latitude and longitude or well known text. By the end of this lesson, you should be able to download and install Geofield and its dependencies, add a Geofield to a content type, and enter in the latitude and longitude for a location node.
Additional resources
One of the features of the Leaflet module is the ability to change the default map marker image. In this lesson, we'll take the iconic Druplicon and transform it into a map marker for a Leaflet map. In this lesson you'll learn how to change the default map marker image both using the field formatter in a content type's display settings as well as in Views.
Additional resources
Out-of-the-box, Leaflet module comes with one map option. In this lesson we'll add the Leaflet More Maps module to our toolbox, try out other map options, and take a look at implications for zoom settings when choosing an alternative base map layer.
Additional resources
In this lesson, we'll add the Markercluster library and contributed Drupal module which will transform the behavior the Leaflet map markers to display clusters instead of individual markers.
Additional resources
Web services, APIs, and structured data are all the rage right now, and with good reason. As more and more internet enabled devices start wanting to make use of the data in our websites, we need to give them some way to interact with that data that isn't point and click in a browser. Enter the Drupal 7 services module.
In this series Joe Shindelar will walk through the services module and teach you how to create a RESTful web services API that exposes Drupal's internal data like nodes and users as JSON or XML. This paves the way for a huge variety of clients using a number of programming languages to access the data contained within your Drupal site, from native mobile applications and partner websites to internet enabled refrigerators.
The first few lessons in the series are focused more on theory. They explain the various terms that are used both in Drupal and the wider web development sphere to describe web services and all their components. Joe describes REST itself and explains why it's a good fit, and discusses Drupal 7's content model and the ways that it lends itself nicely to serializing data into various formats via the services module in order to be consumed in structured and meaningful ways.
Throughout the series we'll see a couple of examples of how to first enable Drupal to return requested data elements as JSON and then subsequently how to properly format an HTTP request to retrieve those elements. Joe will demonstrate making requests to the API via both cURL and the Chrome REST Console. This demonstration will help students to learn about both the Drupal configuration that is required and the way in which any third party applications can request data from Drupal via concrete examples.
With the basics of creating an endpoint and making simple requests out of the way, Joe will demonstrate how to enable authentication via the services module and then use both cURL and the REST Console to explain the authentication handshake: a somewhat complex exchange of a username and password for a session authentication token that takes place in HTTP requests and headers whenever you want to perform an action via the API that requires an authenticated user. This will enable to you create third party applications that can access Drupal as a specific user, allowing for greater personalization.
After that, Joe looks at ways to integrate the lists that site administrators create using the views module with services in order to output their contents as structured data, as well as ways to use views to create entirely new custom services resources, followed by an example of leveraging the power of views exposed filters via services.
Finally, for those scenarios where you simply can't point and click your way to an answer, Joe will teach you how to implement your own custom services resources for both saving and retrieving data from within Drupal, demonstrating the basic knowledge required to allow you to use services to solve all of your own custom API needs.
Things you'll be able to do after completion of this series:
- Understand the basic principles of both web services and RESTful APIs.
- Explain why Drupal is a good fit for web applications that want to allow third party clients to access their data.
- Create a RESTful web services API using the services module for Drupal 7.
- Retrieve data from your Drupal site in both JSON and XML format.
- Create new nodes in Drupal via web services.
- Make authenticated requests to Drupal via web serivces.
- Integrate the views module with services to retrieve views data in various formats.
- Write your own module providing custom services data and actions.
- Create meaningful documentation that will enable others to take advantage of your newly created service.
This series provides information about the services module for both intermediate and advanced Drupal users. Since this module makes use of basic Drupal site building skills and custom views, users should be familiar with those topics. Also, while not required, knowledge of running commands via the command line will be helpful. Finally, if you want to write your own custom services resources you'll need to understand basic module development.
Additional resources
This lesson covers what an API is and why you might want to build one. Joe also explains the basic concepts behind any API and provides real world examples of existing APIs that you're probably familiar with as well as use cases for when and why you might want to build your own.
In this lesson Joe shows you where to locate the services module and it's documentation. Then walks through installing the services module and confirming that it's working. Followed by a quick overview of the module's codebase and a general overview of what the services module provides.
Additional resources
The API that we're going to be building through this series is a REST based API so we need to understand the basic tenants of RESTful web services. In this lesson Joe gives a short presentation explaining the basic terminology, workflow, and tennants of REST based web services.
Additional resources
This lesson walks through defining the URL that will serve as the endpoint for your API as well as all the basic configuration for your new services endpoint with the exception of resource configuration which is covered in the following lesson.
Additional resources
The services module exposes most of Drupal core's data as resources and provides CRUD operations and additional actions for each. In this lesson Joe will look at the available resources, talk about the various CRUD operations and actions and then enable the node resource and demonstrate retrieving node data as JSON from the services endpoint.
Additional resources
JSON Formatter - Chrome plugin to display results of a JSON request in a nicer way.
While cURL may not be the simplest way to interact with a REST API it is the most ubiquitous and the one that is most often referenced in documentation through the web. So to ensure that students have at least a baseline of understanding, and will know how to read the documentation in the future, in this lesson Joe takes a quick look at how to test our API with cURL by retrieving, and creating data.
Example Commands:
`curl http://localhost/demos/services-7x/docroot/api/v1/node/1`
`curl --data '{"title":"hello world!","type":"page"}' --header "Content-Type:application/json" http://localhost/demos/services-7x/docroot/api/v1/node`
Additional resources
Instead of using the CLI to test our API we can use the powerful Chrome REST Console plugin instead. This provides a nice GUI and makes it a little easier to both test and understand what is going on. In this lesson Joe looks at installing the plugin and making basic requests to our API using the REST Console interface.
Additional resources
The Chrome plugin demonstrated in this video is no longer available but there are many alternatives available. Use Postman or search for "REST client" to find tooling options.