Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Panels Primer: 5 Things About Panels for Novices

This is a primer for those novices who've just heard about the Panels module. The content of this article is from two different sources: online introduction, and the mistakes that I, as a novice, have made. Most of the points are so obvious after one masters the module, but may be confusing for those who just start. Any suggestions or corrections would be welcomed.

000 Overview of Panels Module

Panels is an awesome module that increases the functionality and flexibility of a site for the site administrator, the one who administers the site through user interfaces. It panelizes (or divides) a web page into multiple regions. Within each region, panes can be added to display any content. Furthermore, the layout of the panel can be changed freely through tweaking each individual region. At the front end, a granted user can also affect the layout of the panel by dragging and dropping each pane among regions, and/or changing the style of a region. A panel user can even set the selection rules to let people who have different accessibilities see different layouts or contents within the regions.

001 Terminology I: Panel = Panel Page = An Entity Type != A Content Type

When people say “a panel” - more accurately called a panel page - they are not referring to a block or a combination of blocks, rather, a panel is a highly customized page entity containing a URL path completely defined by the panel builder. In this manner, it differs from a basic page that is part of the node system, since a basic page is visited by a URL automatically appointed by the system.

010 The order of panel variants matters

A common mistake made by novices is omitting the significance of the order of variants. As I mentioned in the overview, Panels has a powerful function allowing the site administrator to create different variants of a panel page with different selection rules; when people with different accessibilities visit the page, they will see different variants based on what the site administrator wants them to see. The logic here is that if the visitor passes the selection rules of the first variant, then he or she can see that variant only - the rules of latter variants won't even be checked. In other words, the stricter the selection rules of a variant, the higher it should be ranked.

011 Terminology II: What is Panelizer really?

Panelizer is another module that is usually used with Panels. Just like it sounds, it literally means to transform a specific component of a web page (eg. a block) or a whole node into a pane. In fact, it transforms node as well as other entities like taxonomy into a panel, with all the fields of the entity being transformed into panes. This means the layout of the node can be easily changed from both front-end and back-end. Panels Node, a module shipped with Panels module, has part of Panelizer’s functions; it only provides a panelized node type.

100 Exportation

A panel is exportable by simply choosing the “export” option in page manager or administration page of a panel. Combining with other modules, we may export some types of panes, however, a pane without any assistance from other modules is not exportable manually. For example, Custom Content Panes module can be used to export panes containing basic HTML code only. Views Content Panes module is able to export views in the display of content pane, which is another example of how the pane is exported. If one wants a customized pane to be reusable, he or she has to create a Ctools plugin programmatically.

101 Pane vs. Block

When we use views on a panel page, we can choose the display as content pane or block. It is plausible that a content pane here can be replaced with the pre-existing block. I found some necessaries for it to exist. Firstly, the pane can accept arguments through user interface, while a block needs additional PHP code to achieve that. Secondly, in views, a pane can override all views generated path with a custom path of the panel. Thirdly, the panel system has additional settings that a block system doesn’t have, eg. title overriding, exposed filter, etc.

References:

https://groups.drupal.org/node/143009

https://drupal.org/node/496278

http://www.pixelite.co.nz/article/building-custom-content-panes-aka-ctoo...

http://drupalize.me/series/building-websites-drupal-7-using-panels

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web