In these tutorials on markup in Views, we learned :
- What affects markup in Views
- How to use the Views UI to change markup
- How formats affect markup output
- How to customize row and field wrapper markup
- How to rewrite output with replacement tokens
- How to override Views template files
- How to add a CSS class to your View
As you learned, there are a number of ways to affect markup in Views ranging from utilizing the UI to editing a template file in code.
Ready for a challenge?
Now that you’ve learned all about markup in Views, can you apply what you’ve learned? Use your knowledge of customizing markup using the Views UI and your knowledge of overriding Views template files to apply the HTML markup in the pattern lab prototype to a view of recent posts. Download the demo files and database containing the view of recent posts in the additional resources section below. Contained in the top-level of the files download is a directory called "misc." Inside "misc" you'll find the demo-pattern-lab files:
- The latest posts file is located in
misc/demo-pattern-lab/source/_patterns/02-organisms/03-sections/00-latest-posts.mustache
- The media block file is located in
misc/demo-prototype/source/_patterns/01-molecules/02-blocks/00-media-block.mustache
Use your knowledge of inspecting views template files to locate the read more link markup in order to customize the markup and placement of the read more link, to match the prototype markup. You can find the setting to turn on the more link in the Views UI under the pager section in the middle column.
Here’s another hint: you’ll want to update the field settings for the body field to display a trimmed or summary display instead of the full body value.
Finally, For a bonus challenge, create an image style that matches the prototype image dimensions, and apply it to the image field in your view. To learn more about image styles in views, check out the video Using Image Styles with Views in the Drupalize.Me library.
Good luck with this challenge!
Additional resources
Now let's shift gears and take a look at how using Panels affects markup in Drupal. I will show you some unique-to-Panels concepts as well as how to apply Drupal theming principles to customize markup on a Drupal site that uses Panels.
In the tutorials that follow, you will learn:
- About Panels layouts
- How to add CSS classes using Panels
- How to override the panel pane template file
- What Panels means by “Style”—with a broad overview of Style Plugins and where to go for a deeper dive
Additional resources
Panels — Drupal.org
Chaos Tools Suite (CTools) — Drupal.org
Theming Basics for Drupal 7 — Drupalize.Me
As discussed in the previous tutorial, one thing that affects markup in Drupal when using the Panels module is the Panels layout. In this tutorial, I will provide an overview of how layouts work in Panels. To learn more about how to create your own Panels layout in code, see the related tutorial: Adding Custom Panels Layouts in Your Theme. To learn how to use the Flexible Layout Builder in Panels, see this tutorial: Custom Panels Layouts.
Additional resources
Adding Custom Panels Layouts in Your Theme — Drupalize.Me
Custom Panels Layouts — Drupalize.Me
Chaos Tools Suite (CTools) — Drupal.org
Panels — Drupal.org
In this tutorial, we'll finish setting up the Test page using Page Manager. We'll enable Views Content Panes, create a new content pane display in our view of recent articles, and place that content pane in the panel page.
Additional resources
Overview of Views Content Panes — Drupalize.Me
Chaos Tools Suite (CTools) — Drupal.org
Panels — Drupal.org
In this tutorial, I will show you how to add and remove CSS classes from the body tag using Panels. I will also point out the other CSS-related settings and the pros and cons of each one.
Additional resources
Building Websites in Drupal 7 using Panels — Drupalize.Me
Chaos Tools Suite (CTools) — Drupal.org
Panels — Drupal.org
In this tutorial, I will demonstrate how to add a wrapper div and a class around, and just outside, the Panels layout markup, using the Panels administrative console.
Additional resources
Building Websites in Drupal 7 using Panels — Drupalize.Me
Chaos Tools Suite (CTools) — Drupal.org
Panels — Drupal.org
In this tutorial, I'll walk you through how to add a CSS class or ID to a panel pane using the Panels administrative console.
Additional resources
Building Websites in Drupal 7 using Panels — Drupalize.Me
Chaos Tools Suite (CTools) — Drupal.org
Panels — Drupal.org
The panel pane template file controls the markup for the panel pane container. When you place content into a panel region, it is wrapped by a container called the panel pane. To change this wrapper markup, you will need to copy the panels pane template file into your theme’s templates directory. Let’s walk through this process in this tutorial.
Additional resources
Building Websites in Drupal 7 using Panels — Drupalize.Me
Chaos Tools Suite (CTools) — Drupal.org
Panels — Drupal.org
In this tutorial, we'll take a brief look at what Panels means by "Style" as applied to a region or panel, and I'll walk you through the settings form and how to change a style for a panel pane using the Panels administrative console.
For a more in-depth look at Panels Style Plugins, including how to create your own, check out these related tutorials:
Additional resources
Customize Panels Styles with CTools Style Plugins
Styling Panel Panes with Stylizer
Chaos Tools Suite (CTools) — Drupal.org
Panels — Drupal.org
In this lesson, I provide a recap of the Panels-related tutorials in this series.
Additional resources
Building Websites in Drupal 7 using Panels — Drupalize.Me
Customize Panels Styles with CTools Style Plugins — Drupalize.Me
Display Suite is another popular module for handling the layout and display of content on a Drupal site. In this next set of tutorials, we'll take a look at how markup is affected in Drupal when using Display Suite.
Additional resources
In this tutorial, I’ll show you how to create a custom layout to use in Display Suite. We’ll take a look at the instructions in Display Suite’s ds.api.php file to find out how to provide our own custom layout. In this process, we’ll take a shortcut and copy a layout from Display Suite into my custom theme and modify it. In the next tutorial, we’ll look at the drush command ds-build
which allows you to quickly scaffold a display suite custom layout in your module or theme.
Additional resources
Now that we have gained an understanding of how to create a custom layout manually (in the previous tutorial), we’ll look at the drush command ds-build
which allows you to quickly scaffold a Display Suite custom layout in your module or theme.
Additional resources
In this tutorial, I will show you how to add a CSS class to apply to a region using Display Suite.
Additional resources
As Drupal site-builders and developers we are all very aware that Drupal 7 is not the most useful product out of the box. We constantly add modules and custom code to make Drupal do what we need. There is nothing wrong with this, in fact it is what attracts people to using Drupal in the first place. The block system that comes with core is what we get after installation as our real only means to laying "stuff" out for our website. People have done things like turning nodes into blocks, or making every block on our a site a view. These concepts work, but have a lot of draw backs for usability and performance. There are lots of layout tools to use, but this series is going to take a look at the Context and Bean modules. These two modules are really two completely different modules but when used together give us some pretty powerful options in place of Drupal's core block system.
Additional resources
One of the key problems with the block system in core is it's very limiting. You are limited to a small set of tools for when and how to show a block. Once you lay out your blocks you are basically done—blocks can't be placed in multiple regions. Most importantly, block configurations are not exportable. With the Context module, you lay things out based on the context of your site. A block can exist in one region for one context and a different region for another. Essentially Context is a more advanced block placement form.
In this lesson we'll get started with Context by installing the module on our site, and then walking through the user interface we have to work with. We'll discuss things like conditions and reactions, and see how things are set up.
In this lesson we will build our first simple context. We will create a custom block that contains copyright information. We will use Context and the "site-wide" condition to place this custom block in the footer region of our site.
In this lesson we will perform a simple operation that site builders do when using the Context module. This is not necessary, but a good idea if there are multiple people managing your site. We will disable all blocks in the block UI since we will be using the Context module to manage this part of our website. The core block UI will then only be used to manage block titles as Context does not allow for this (a disadvantage we learned about previously).
In this lesson we will discuss different use cases for when one would use Context module. We will demo a site that has a home page and a user dashboard that acts as an authenticated users home page. We will demonstrate one of the advantages of Context by placing blocks in different locations depending on which page we're looking at.