Viewers: in countries Watching now:
In this course, Chaz Chumley takes you through the process of transitioning a Drupal website to a responsive model that automatically tailors and sizes content for a wide range of displays, from desktops to mobile devices.
The course starts with setting up the Drupal environment in Acquia and defines some basic principles of responsive design before moving on to creating a new Drupal theme with fluid layouts, fluid media, and responsive tables and forms. Chaz also covers writing media queries, which allow you to create different style sheets for each device type.
The course wraps up with a look at Respond.js and content-aware image sizing in Drupal—responsive design tools that can optimize your project for maximum performance.
When you think about in Drupal, you may not always think about tabular data. But in general, there are only two places you may have tabular data to work with. The first is the end user, creating tabular data using the WYSIWYG inside a node or a block, the other is the output of the view of data from various content types. In this section we will cover tabular data in views and how to modify the HTML for our needs so that we can apply the responsive table's techniques we learned in the previous movie. To begin with, I am already logged in, but if you need to log in, do so at this time and then go ahead and navigate over to Structure and Views.
In order to do this technique, I actually need to create a view first. so I am going to go ahead and click on Add new view, I am going to give this View a name of tables, and then this is going to be a Content Of Type All. I am going to create a page called tables with the Path of tables and the Display Format is going to be Table of fields. From here I am going to click on Continue & edit, and right now if I scroll down all I have is a table of the Titles of the content that is currently inside my Drupal instance, I want to add a couple of more columns.
Let's go to FIELDS, click on add, Filter the Content, and let's look for the Author uid. We'll go ahead and select that click Apply, leave the defaults and click Apply (all displays). Now if I scroll down I have two columns of data. Let's go ahead and add one more column. Scroll back up to FIELDS, click on add, Filter the Content, and this time let's look for let's say the Last comment author. Go ahead and select that, click on Apply (all displays), Apply (all displays) again, and now I should have three columns of data. That works for me.
Go ahead and scroll back up and click on Save. Now that I have a view that has tabular data in it, let's go ahead and browse to that page real quick and see what we have. Remember, this is called tables, so if I go to the tables page--here you go--I see a table of tabular data on this particular page, and if I go to resize it, I am back to the squishy squeezed-in problem that we have with most tables. Let's go ahead and open up the Chrome developer tools, let's go ahead and inspect the table, and if we notice here we have this class of views-table cols-3 which may help us while doing some theming; however, I need to be able to put the class of responsive on here, and currently the only way to do this is by actually creating a views template. Let's take a look at how to do that.
Go ahead and close the Chrome developer tools, let's go back to Structure > Views, click on and edit for our tables view, and then over on the Advanced tab if I expand that and scroll down I see a section called Theme, and if I click on Information, this shows me the output of the theme for this particular view, and I can modify these by creating copies of these either with the default view names that are specified in bold or by creating any of the view names here that I have.
This particular time, I am going to want to create a template for views-view-table.tpl.php. Let's see how we would go about doing that. Go ahead and close this, and let's go ahead and tab over to our editor real quick, and I want to show you something. Inside our theme we actually have a templates folder, and these are some of the templates that were set up just for demonstration purposes for this series. If I expand views, I can see that I already have some templates in there, but I do not have one for views-view-table, so how do I know exactly what goes inside that? Well, if I scroll up to sites/all/modules and expand the modules folder and then the views folder and then look under theme, I can see some default templates that I can use, and one of them is actually views-view-table.
I am going to open that, I am going to copy the contents, I am then going to close the folder, close the views folder, close the modules folder, go back to my templates, right-click on views, and say New Text Document. I need to call this views-view-table.tpl.php. With that created, I am going to copy the contents from that other view and then paste it inside of it. I'll go ahead and hit Save and then scroll up and take a look at what we have.
This says this is a template to display a view as a table, and I can actually see the table and some classes that are being used. For demonstration purposes, I really don't care about these other classes that are being applied, so I am actually going to remove this, and then I'm actually going to hand code class="responsive" similar to what we did inside the WYSIWYG. However, this time I am going to save it, and if I tab back over to my browser, flush the cache, and then browse back over to that page, open up the Chrome developer tools real quick, and let's inspect this table.
Now I have a table with a class of responsive, and the nice thing about using the template in method is any view that I create, that I choose to use as tables, will now have this class, and with that previous technique that we learned, all the tables will now be responsive. Let's close the Chrome developer tools, resize this, and see what we get. There is our scrollbar for our content, there's a scrollbar for our column if our column has information in here that's too wide. Responsive tables do not take a lot of work to accomplish, but we need to make sure we don't overlook them when designing in Drupal.
Knowing how to modify the HTML output and then apply the appropriate CSS or jQuery is just a small task to ensure that our Drupal 7 design is responsive. One more thing we want to take a look at before we can be proud that our Drupal design is completely responsive is forms. Let's take a look at responsive forms now.
There are currently no FAQs about Responsive Design with Drupal.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.