"Become a Panels rockstar in just one day," Will Jaspers: Drupal Camp Twin Cities 2011

Panels is one of those very important Drupal modules that many people use: not quite as common as Views or CCK, but it’s up there. Panels allows you to place content in various areas beyond the default regions in a Drupal theme, to put a complex multi-column layout in your content area, for example. To this point, I have not learned how to use Panels, but at Drupa Camp Twin Cities 2011, Will Jaspers gave a presentation on how to “Become a Panels rockstar in just one day.” Here is the session description:

Panels is a fantastic module which provides much needed flexibility to aggregate content from varying sources and help users and administrators alike use and re-purpose the information your website provides.

Assuming we can cover all of this in just one hour, you’ll learn:

  • What a Panel, a Region and a Pane are.
  • How to use the Panels Editor
  • How to put custom content into a Pane
  • How to use Contexts and Relationships
  • How to put views into your panels
  • How to make your Views re-usable for Panels
  • How to use the Page Manager
  • How to make Custom Access Rules
  • How to use Views as Contexts
  • A few themes that provide custom layouts
  • How to code your very-own layout plugin
  • How to use Panel layouts in Views

My notes on the session are available after the break.

This demo of Panels will be done in Drupal 6, because of some bugs in Drupal 7, but Panels essentially works exactly the same in Drupal 7 as what we will see today.

What are panels?

Panels are a flexible way to display various content with specific access controls simultaneously.

What panels are not

  • Replacement for all your content types
  • Way to make freeform HTML pages
  • Not as easy as making grilled cheese

Should I use panels?

  • It depends
  • How big is your site going to be?
  • How important are any two different pieces of data to a certain user or persona?
  • What content is needed and when?
  • Context matters

Why not just use context modules?

  • Reactions aren’t always so simple
  • Can work together, but not in/as a panel
  • Really big sites can be quite complex
  • Large quantities of context reactions might be hard to manage
  • Stressed about working with multiply layouts?
  • What if I want to re-use the data on the page I am currently on?

What modules do I need?


  • Chaos Tools suite (ctools)
  • Panels
  • Views
  • Page manager

Other modules can be added in for additional functionality.


  • Custom content panes


  • Views content panes
  • Custom rulesets
  • Mini-panels

Panel nodes

  • Great way to learn how to use panels
  • Customizable layouts
  • Can add/remove blocks/forms/content as you please
  • Limited access to more complex information, such as views
  • Not a solution for all content

What are the components of a panel?

  • Panels contain regions
  • Regions contain panes
  • Panes contain everything else

What’s a region?

  • Building blocks of a panel
  • Can be identified using custom classes and IDs
  • Contain panes

What’s a pane?

  • Panes are meat of a panel
  • Any content added to panel is treated as a pane
  • Can customize display with Stylizer or custom CSS

Page manager

What is a page?

  • Not a standard HTML page
  • URL which can:
    • Respond with specific HTTP status code
    • Display custom content
    • Help administrators manage site
    • Control who has access to it
    • Pull content from different sources for later display


  • A deviation from the norm.
  • A way to make one page act like several
  • An opportunity to provide different levels of access to content
  • A way to take some complexity out of your site

Selection criteria

  • Allows the site to filter pages and variants on a myriad of attributes.
  • Can be customized to meet specific needs.
  • Can use criteria from contexts given to the page.

Why would I usea Selection rule?

  • Without them, the page will take over all potential instances of content.
  • Sometimes different types of visitors need different content.

What is a context?

  • Related information to the subject at-hand.
  • Information that can be re-purposed throughout the site.
  • Additional information the user wants

Can contexts be inherited?

  • In short no.
  • If a Context is added to a Page a “Panel Node” cannot inherit it.
  • It can be used to include specific content.
  • Contexts can be passed to Views.

Using Views as Contexts

  • Bring content into the page without loading everything.
  • Use exposed views operators how you please.
  • Give the user control to specific parts of the view.

Custom access rules

  • Allows for complex access rules to be re-used and re-purposed throughout pages and panels.
  • Exportable

Custom layouts

  • Use Panels layouts as Views row formatters.
  • Exportable

Why not build custom layouts with the layout manager?

  • We like clean output.
  • Hard to extend into 960.gs and other structural frameworks: Some themes provide these
  • Extra step talking to the database
  • Less control over CSS

Hard Coded Layout Plugins

  • When built-in layouts just don’t do it.
  • Only one line of code required to tell Panels where to look: plugins[layouts][] = foldername
  • Where should I look for sample code? Check out the Zen theme and Adaptive Themes (AT) Panels

Creating a layout plugin

Your layout plugin will include:

My_layout.inc (Plugin file)

Contains the array of information regarding your layout for Panels

Layout Name
Groups layouts together
User-facing .tpl template
User-facing .css file
Admin Template
Admin-facing .tpl
Admin CSS
Admin-specialized .css
Array of regions in template
My_layout.css (Common CSS for this layout)
My_layout.tpl.php (Output template)

How should I structure it?

Are you using a grid system?

What code is required?

Drupal 6

Drupal 7

Caveats: Will be used for any user if no admin template exists.

Admin.css (Optional Admin CSS file)
Admin.tpl.php (Optional Admin template)

How should I structure it?

Who can access it?

  • This is only visible to administrators.

Why use it?

  • Sometimes you/your client needs complex displays that aren’t very easy to edit/add content to.
  • This makes it a breeze for admins to experience your panel structure exactly as is required!


mcad.edu uses Panels

My take

I will be completely honest, I still feel totally lost about how to use panels. I picked out a few key facts:

  • Drupal themes have regions in which you can put content. Panels allows you to create mini-regions within a region in which you can put content, allowing you put a sub-layout within a larger layout.
  • There is a wide variety of types of content you can put into the individual panes within the regions of a panel.
  • You can use views to create the content that goes into a panel’s pane.
  • Panels can be turned on based on the context of the page. There are far more options when looking at the context of a page than, say, just the URL of a page.

There is a lot of detail above that I copied down. I suspect that I may need to learn that detail more by doing and working through problems rather than by trying to understand panels in an abstract sense.