7 min read

(For more resources on Drupal, see here.)

Introduction

Drupal Panels are distinct pieces of rectangular content that create a custom layout of the page—where different Panels are more visible and presentable as a structured web page. Panels is a freely-distributed, open source module developed for Drupal 6. With Panels, you can display various content in a customizable grid layout on one page. Each page created by Panels can include a unique structure and content. Using the drag-and-drop user interface, you select a design for the layout and position various kinds of content (or add custom content) within that layout.

Panels integrates with other Drupal modules like Views and CCK. Permissions, deciding which users can view which elements, are also integrated into Panels. You can even override system pages such as the display of keywords (taxonomy) and individual content pages (nodes).

In the next section, we will see what the Panels can actually do, as defined on drupal.org: http://drupal.org/project/panels.

Basically, Panels will help you to arrange a large content on a single page. While Panels can be used to arrange a lot of content on a single page, it is equally useful for small amounts of related content and/or teasers. Panels support styles, which control how individual content’s panes, regions within a Panel, and the entire Panels will be rendered. While Panels ship with few styles, styles can be provided as plugins by modules, as well as by themes:

  • The User Interface is nice for visually designing a layout, but a real HTML guru doesn’t want the somewhat weighty HTML that this will create. Modules and themes can provide custom layouts that can fit a designer’s exacting specifications, but still allow the site builders to place content wherever they like.
  • Panels include a pluggable caching mechanism: a single cache type is included, the ‘simple’ cache, which is time-based. Since most sites have very specific caching needs based upon the content and traffic patterns, this system was designed to let sites that need to devise their own triggers for cache clearing and implement plugins that will work with Panels.
  • A cache mechanism can be defined for each pane or region with the Panel page. Simple caching is a time-based cache. This is a hard limit, and once cached, it will remain that way until the time limit expires. If “arguments” are selected, this content will be cached per individual argument to the entire display; if “contexts” are selected, this content will be cached per unique context in the pane or display; if “neither”, there will be only one cache for this pane.

  • Panels can also be cached as a whole, meaning the entire output of the Panels can be cached, or individual content panes that are heavy, like large views, can be cached.
  • Panels can be integrated with the Drupal module Organic Groups through the #og_Panels module to allow individual groups to have their own customized layouts.
  • Panels integrates Views to allow administrators to add any view as content. We will discuss Module Integration in the coming recipes.

Shown in the previous screenshot is one of the example sites that use Panels 3 for their home page (http://concernfast.org). The home page is built using a custom Panels 3 layout with a couple of dedicated Content types that are used to build nodes to drop into the various Panels areas. The case study can be found at: http://drupal.org/node/629860.

Panels arrange your site content into an easy navigational pattern, which can be clearly seen in the following screenshot.

There are several terms often used within Panels that administrators should become familiar with as we will be using the same throughout the recipes. The common terms in Panels are:

  • Panels page: The page that will display your Panels. This could be the front page of a site, a news page, and so on. These pages are given a path just like any other node.
  • Panels: A container for content. A Panel can have several pieces of content within it, and can be styled.
  • Pane: A unit of content in a Panel. This can be a node, view, arbitrary HTML code, and so on. Panes can be shifted up and down within a Panel and moved from one Panel to another.
  • Layout: Provides a pre-defined collection of Panels that you can select from. A layout might have two columns, a header, footer, or three columns in the middle, or even seven Panels stacked like bricks.

Setting up Ctools and Panels

We will now set up Ctools, which is required for Panels. “Chaos tools” is a centralized library, which is used by the most powerful modules of Drupal Panels and views. Most functions in Panels are inherited from the chaos library.

Getting ready

Download the Panels modules for the Drupal website: http://drupal.org/project/Panels

You would need Ctools as a dependency module, which can be downloaded from: http://drupal.org/project/ctools

How to do it…

  1. Upload both the files, Ctools and Panels, into /sites/all/modules. It is always a best practice to keep the installed modules separate from the “core” (the files that install with Drupal) into the /sites/all/modules folder. This makes it easy to upgrade the modules at a later stage when your site becomes complex and has too many modules.
  2. Go to the modules page in admin (Admin| Site Building | Modules) and enable Ctools, then enable Panels. Go to permissions (Admin | User Management | Permissions) and give site builders permission to use Panels.
  3. Enable the Page manager module in the Chaos tools suite. This module enables the page manager for Panels.
  4. To integrate views with Panels, enable the Views content panes module too. We will discuss more about views later on.
  5. Enable Panels and set the permissions.
  6. You will need to enable Panel nodes, the Panel module, and Mini panels too (as shown in the following screenshot) as we will use the same in our advanced recipes.
  7. Go to administer by module in the Site building | Modules.
  8. Here, you find the Panels User Interface.

There is more

Chaos tools suite includes the following tools that form the base of the Panels module. You do not need to go into the details of it to use Panels but it is good to know what it includes. This is the powerhouse that makes Panels the most efficient tool to design complex layouts:

  • Plugins—tools to make it easy for modules to let other modules implement plugins from .inc files.
  • Exportables—tools to make it easier for modules to have objects that live in database or live in code, such as ‘default views’.
  • AJAX responder—tools to make it easier for the server to handle AJAX requests and tell the client what to do with them.
  • Form tools—tools to make it easier for forms to deal with AJAX.
  • Object caching—tool to make it easier to edit an object across multiple page requests and cache the editing work.
  • Contexts—the notion of wrapping objects in a unified wrapper and providing an API to create and accept these contexts as input.
  • Modal dialog—tool to make it simple to put a form in a modal dialog.
  • Dependent—a simple form widget to make form items appear and disappear based upon the selections in another item.
  • Content—pluggable Content types used as panes in Panels and other modules like Dashboard.
  • Form wizard—an API to make multi-step forms much easier.
  • CSS tools—tools to cache and sanitize CSS easily to make user input CSS safe.

How it works…

Now, we have our Panels UI ready to generate layouts. We will discuss each of them in the following recipes.

The Panels dashboard will help you to generate the layouts for Drupal with ease.

LEAVE A REPLY

Please enter your comment!
Please enter your name here