I am trying to follow this tutorial, but it does not explain the concept of variant very clearly. It does not provide a definition of it.

Can someone clarify this concept in plain English? What are the practical cases where you would use variants?

  • 2
    Variants aren't a core Drupal concept, but apparently a Panels/Page Manager concept. Retagged with panels.
    – user7
    Feb 6, 2012 at 6:51

3 Answers 3


Variants are to do with Panels, and are a way to vary an output slightly. Variants can inherit most of their behaviour and can override what they need. If you have experience with Views then it is most closely like having another display. The variant may be changing how the panel is laid out or may add other elements. The decision to use one variant or the other can be based on selection rules or contexts, selection rules being more global and context more about what is being looked at, i.e. the node being viewed etc.

  • So if we were talking OO, and B inherits A, B is a variant of A in Drupal? Feb 6, 2012 at 7:06
  • 3
    Hmm, I don't know that variants are that strict, more like A and B both inherit from some other object that is the page itself.
    – Malks
    Feb 6, 2012 at 7:17

I've never been forced to define it before, but here's an attempt at it.

"A variant is a specific response to a request on a Page", in the Page manager. Mostly, using Panels, this involves the rendering of a node or other full page, but not always.

While there are some similarities to "Views displays", unlike Displays, Variants have no inheritance between each other. All variants on any particular Page has the same basic access rules if any, and starts of with whatever context-objects that Page manager derives from the URL, but are not aware of eachother in any way. Based on selection rules, they are evaluated from top to bottom. The first selection rule to return TRUE, gets picked.

A common example is to separate two different content/node-types from each other, allowing you to render them entirely differently. Since each variant may pick its own layout, and place fields/forms/etc in an arbitrary way, the "Article" and "Blog" types may look entirely different. In this case the variants would correspond to node-article.tpl.php and node-blog.tpl.php.

There are various other "Responders" available for Variants that don't involve the use of Panels, such as Contextual administration and plain HTTP Response codes, but I believe this answer is long enough as it is.


Letharion's answer and Malks' answer are both very good, but let me add something I think may be helpful. (And please leave a comment if you think I got some of this wrong, and I'll correct it.)

You can think of Panels as a replacement for Blocks, sort of like they could have been called "Smart Blocks" (or context-aware blocks, or something like that). Panels can appear differently in different contexts, since sometimes you may want your block's contents to behave (appear) slightly differently on one page than on the other. Doing this with Blocks can be a bit kludgey, so Panels attempt to improve matters.

A variant is just a different version or variation of how to display things. You can set context and selection rules to determine which variant to use.

So in short, a variant is just a version of your blockpanel, and every panel needs at least one version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.