Skip to Content
RSSGrab the RSS feed! ->

How to create a panels style plugin

Creating panels styles can be very powerful. You can define certain styles for your client to choose from, so they can choose what type of display the panel pane will be like. This way you keep the workflow clean, your code under revision control, your themer gets to keep his sanity, and your concious stays clear.

This article assumes you know about running panels, and more or less what the nomenclature is. You should know also that panels now uses ctools, which is is primarily a set of APIs and tools to improve the developer experience.

So, what we'll be doing here is actually creating a ctools plugin, to implement a new panels style. Sorry if I'm confusing you already, don't worry, it's actually quite straight forward, we want to be able to do this:

... and then this:

OK, now to the meat of it. We'll call our module ctoolsplugins.

1. Create a new module, and tell ctools about our plugins

What you need is very basic, an info file and a module file. So far, nothing new.

1.1 Declare our dependencies

So we obviously need ctools module on our site, and well, the plugin wouldn't make much sense without panels and page_manager, so:

; $Id:
name = Ctools Plugins
description = Our custom ctools plugins
core = 6.x
dependencies[] = ctools
dependencies[] = panels
dependencies[] = page_manager
package = Chaos tool suite

1.2 Implement hook_ctools_plugin_directory to tell ctools about our plugins

In our module file, of course, we'll implement this function, that will check if ctools if looking for style plugins, and lets if so, it will let it know where ours are:

  * Implementation of hook_ctools_plugin_directory().
function ctoolsplugins_ctools_plugin_directory($module, $plugin) {
  if (
$module == 'panels' && $plugin == 'styles') {
'plugins/' . $plugin;

2. Prepare our file structure for the plugins, and create our plugin file.

This image is pretty self explanatory:

We'll call our plugin 'collapsible', so we create inside ctoolsplugins/plugins/styles/ a file called

3. Implement our style plugin in

3.1 Define your style goals and necessities.

OK, Here you should think about what you are going to do with the plugin.

  • Is it just for markup?
  • Will you be offering different options?
  • Will you be implementing javascript on it?

In our case, we'll take the opportunity, to teach you another thing that ctools has, the collapsible div utility. So our style will basically convert any panels pane, into a collapsible panels pane:

And because we are friendly developers (or like not to be ever bothered after developing it), we'll give the user a chance to configure if they want the pane to start opened or closed. That means an extra settings form, so we can have this:

3.2 Imlement hook_panels_style_info

The naming is very important here, it should be modulename_stylename_panels_style. You basically return an array, defining your style:

* @file
* Definition of the 'collapsible' panel style.

* Implementation of hook_panels_style_info().
function ctoolsplugins_collapsible_panels_styles() {
  return array(
'title' => t('Collapsible div'),
'description' => t('Display the pane in a collapsible div.'),
'render pane' => 'ctoolsplugins_collapsible_style_render_pane',
'pane settings form' => 'ctoolsplugins_collapsible_style_settings_form',

'title' and 'description' are pretty self explanatory.
'render pane' specifies the theme function we'll be providing for rendering the pane. Watch the naming convention.
'pane settings form' specifies the callback function which provides the extra settings form, that we'll be using for our start up options. Watch the naming convention.

3.3 Define the settings form callback.

The name of the function will be what you specified in 'pane settings form' earlier. Just provide a new array inside $form, for each configuration you want the user to specify. See the FAPI documentation for reference.

* Settings form callback.
function ctoolsplugins_collapsible_style_settings_form($style_settings) {
$form['collapsed'] = array(
'#type' => 'select',
'#title' => t('Startup behaviour'),
'#options' => array(
0 => t('Start opened'),
1 => t('Start collapsed'),
'#default_value' => (isset($style_settings['collapsed'])) ? $style_settings['collapsed'] : 'opened',
'#description' => t('Choose whether you want the pane to start collapsed or opened'),


This is pretty straight forward, in our case we provide two options, one to start opened and one to start collapsed. If collapsed is chosen, the value will be 1.

3.4 Define the render callback function.

The name of the function will be what you previously specified in 'render pane'. This is just a theme function, and where you have the chance of altering what will be shown to the user when viewing the page.

* Render callback.
* @ingroup themeable
function theme_ctoolsplugins_collapsible_style_render_pane($content, $pane, $display) {
$style_settings = $pane->style['settings']; // good idea for readability of code if you have a ton of settings
$start_settings = $style_settings['collapsed']; // we can do this be cause the only values possible are 0 or 1

$pane_content = $content->content;

  if (
$content->title) {
$pane_title = '<h2 class="pane-title">'. $content->title .'</h2>';

// theme('ctools_collapsible', $handle, $content, $collapsed);
$result = theme('ctools_collapsible', $pane_title, $pane_content, $start_settings);

// if we don't have a pane title, we just print out the content as normaly, since there's no handle
else {
$result = $pane_content;


Important to note here, is that our user's specified settings are inside $pane->style['settings']. In this example we check if there's a title available, and if so we implement the ctools_collapsible theme function to get our collapsible panes. Other wise we don't have a handle, and we just return the content as normal.

And that is it. Hope you found the article useful, and if you'd like me to write up some more articles about writing plugins for panels/ctools, drop a comment with your question/suggestion!

UPDATE:You can also provide a style plugin in your theme, as shown in this fine tutorial.

ctoolsplugins.tar.gz1.3 KB

113 responses to this article.


Funciona de maravilla!

Funciona de maravilla! Gracias por hacer este post tan claro, brindando el paso a una goleada para los nuevitos! Peter de b&b Venecia


Les femmes bénéficient

Les femmes bénéficient parfois de ce traitement
dans le cadre d'une alopécie féminine diffuse banale mais à une focus inférieure, à
2 %. Il arrive que ce produit entraîne quelques irritations, pellicules ou allergy symptoms.
Il existe des shampoings qui peuvent atténuer les irritations et les démangeaisons.


Hey there! Do you know if

Hey there! Do you know if they make any plugins to assist
with Search Engine Optimization? I'm trying to get my blog to
rank for some targeted keywords but I'm not seeing very good gains.
If you know of any please share. Appreciate it!


Thank you for writing this,

Thank you for writing this, it's saved me a ton of time in figuring this out myself. One minor correction, in step 1.2, I think you're if statement shoudl be the following, to prevent loading the plugin for some other module who might also use plugins names 'styles'

if ($plugin == 'styles') {

should be

if ('panels' == $module && 'styles' == $plugin) {


Excelent point Oscar, I have

Excelent point Oscar, I have updated the code in the post, thanks for pointing this out, and glad to hear it saved you time!


This is especially important

This is especially important for low-budget projects. Stone countertops can be anywhere from
$5 to $150 per square foot. During the process of refining the gas,
a chemical known as Mercaptan is added to the gas for it to have a
distinctive odour for safety purposes.


Hello Dear, are you truly

Hello Dear, are you truly visiting this web site daily, if so after that you will
absolutely obtain fastidious experience.


Heya are using Wordpress for

Heya are using Wordpress for your site platform? I'm new to the blog world but
I'm trying to get started and create my own. Do you require any coding expertise to make
your own blog? Any help would be really appreciated!


Hiya! I know this is kinda

Hiya! I know this is kinda off topic but I'd figured I'dask.
Would you be interested in exchanging links or maybe guest authoring a blog
post or vice-versa? My website discusses a
lot of the same subjects as yours and I feel we could greatly
benefit from each other. If you are interested feel free to shoot me
an email. I look forward to hearing from you! Terrific blog by the way!


Hi there! Do you know if they

Hi there! Do you know if they make any plugins to help with SEO?
I'm trying to get my blog to rank for some targeted keywords
but I'm not seeing very good gains. If you know of any please share.
Thank you!


One thing I learned, is for

One thing I learned, is for your style to be available as a region style, you need to define a 'render panel' function, for it to be available as a style for a single pane, defined a 'render pane' function.


I just tried this and now I

I just tried this and now I can't access the panels dashboard. I get the WSOD.


The WSOD is most likely an

The WSOD is most likely an indication that php is runing out of memory on your server. This has nothing to do with what is explained here, but rather a problem with your server's configuration.
Check out this link about what could be causing this: , but I find that most of the cases this is fixed by increasing memory_limit in your server's php.ini file.


Tried the above module in D7,

Tried the above module in D7, but no dice. It shows up in the styles menu, but the field never gets collapsed upon viewing it.


The Denver Search Engine

The Denver Search Engine Optimizers at Fusionbox spend
our careers making an attempt to figure out what the algorithm likes best and assist talk that with throughout the design, growth and advertising process.

If there was no seo then webmasters could be enjoying quick
and unfastened with web sites and search algorithms would have a harder
time determining a website's value and authority.


Hi there everyone, it's my

Hi there everyone, it's my first visit at this web site,
and post is in fact fruitful for me, keep up posting these types of content.


Hi I am so happy I found your

Hi I am so happy I found your web site, I really found you by mistake,
while I was browsing on Yahoo for something else, Anyways I
am here now and would just like to say thank you for a marvelous post
and a all round exciting blog (I also love the theme/design),
I don't have time to look over it all at the moment but I have saved
it and also added your RSS feeds, so when I have time I will be
back to read a lot more, Please do keep up the awesome work.


This site was... how do you

This site was... how do you say it? Relevant!! Finally I've
found something which helped me. Thanks a lot!


For example, the Web Editor I

For example, the Web Editor I use includes a page view for "Source", that may show all the code
with the page. If you want to determine if keyword phrases are giving you achievement and
then add brand new ones, you can refer to the Google Keyword tool.
Another drawback is the method that IT developers connect to these new
databases is via modern programming languages for example
Java, Python, and Perl.


With havin so much content do

With havin so much content do you ever run into any issues of plagoriksm or copyright infringement?
My blog has a lot of unique content I've either written myself or outsourced but it looks like a lot of it
is popping it up all over the web without my permission. Do you know any
ways to help protect against content from being stolen?
I'd genuinely appreciate it.


Hello, I desire to subscribe

Hello, I desire to subscribe for this web site to obtain newest updates, soo where can i
do it please assist.


What's up, this weekend is

What's up, this weekend is nice for me, ffor tthe reazson that this moment i am reading this fantastic informative paragraph here att mmy house.


This post ranks high in

This post ranks high in Google for Drupal Panels Tabs, but it applies to D6. The following patch at d.o will get you tabs in Panels for Drupal 7 - vertical tabs by default, but also horizontal tabs will be enabled as an option if you also have the field group module enabled.

Tabs style plugin: Vertical Tabs in core! (for Drupal 7)

Field Group Module:


People will paint a shamrock

People will paint a shamrock on a face, wear a hat, wear a flag, wear something green, dye or spray their hair green, wear
a Leprechaun and so on. Cool Minecraft seeds can now be
attained straight to the web servers hosting the sport.
Typically this age cap is 18 or 21 yoa in most Western nations
throughout the world. Keep your child's talents sharp over extended breaks
with his fantastic confidence in those skills will stay
strong. But your legs really should not be looking pillar holding the building.
These vagrants were successful in their own way
until they succumbed to the extra weight of social or economic stress and walked into some kind of escapism.
If you're one in the many parents feeling the stress of attempting to
remain positive with bored, cooped-up kids, the indoor activities for children the following could possibly allow you to beat the temperature for one more week.
The first movie became available in 07 and would have been a
quick hit effortlessly people and rejuvenated a person's eye within the toys which will first became available beneath
the Hasbro line inside 1984. Sometimes these people just who struggle around
things, particularly math, are ashamed regarding their challenges.
A Golf Club Grip, Baseball Bat and mini Tennis Racket Grip, all with the addons quickly attach quickly and on the
Wii-mote. It is with this aim in mind of
moulding your children into mature and responsible citizens that this School encourages the students to take
part in various co-curricular activities locked in school like
music, dance, arts and sports. Then the two of you begin the most common trail, coffee, film, and
dinner. "Travian" ranked first, accompanied
by a "vertical and horizontal world", "Hero", "basketball manager," "dance street" therefore on, but far not all.
Has become popular round the world and represent
synonymous for games in general. Look at the slide show to find out these best apps for girls.
The greatest benefit of Witty Dicie online games for youngsters is definitely an opportunity it offers
a superior children and parents to invest added time together and enhance communication between family members.
Learn where to find puzzle games on the internet and throw open the door
to numerous options for your challenging entertainment.
The Intec PS2 Wireless Kombat Arcade Stick is really a wireless PS2 controller that may allow one to fight with so much accuracy and basically
an instant response time. There are math games made to teach every type of
math. Sega won't get the maximum amount of credit as they deserve for
a few of those games, however any Dreamcast owner know these games
were simply unique to its time. The game has ended when it
is possible to will no longer place lines on the grid.
Hence I prefer to look for any discount playing addictive games
online when ever I am free, bored or require some consist of your present day's activity to get a brief
amount of time. It takes around three hours to get a Wii game burned.
The retro-style graphics that seem to be so competent on a phone look greater on Android wearable Smartwatch.
There are many exciting fighting options are available.


I love what you guys tend to

I love what you guys tend to be up too. This type oof clever work and reporting!
Keep up the awesome works guys I've added you guys to blogroll.


My partner and I absolutely

My partner and I absolutely love your blog
and find nearly all of your post's to be what precisely I'm looking for.
Do you offer guest writers to write content for you?

I wouldn't mind publishing a post or elaborating on a lot of
the subjects you write about here. Again, awesome website!


Tremendous issues here. I am

Tremendous issues here. I am very satisfied to peer your
post. Thank you a lot and I'm having a look ahead to contact
you. Will you kindly drop me a e-mail?


Thank you a bunch for sharing

Thank you a bunch for sharing this with all folks you really recognize what you
are talking approximately! Bookmarked. Please also visit my web site =).

We may have a link trade contract among us


Hey there, I think your site

Hey there, I think your site might be having browser compatibility issues.

When I look at your blog in Chrome, it looks fine but when opening in Internet Explorer,
it has some overlapping. I just wanted to give you a
quick heads up! Other then that, very good blog!


Learn the instruction and

Learn the instruction and follow them when you speeding your bike, full control on speed limit, taking turn or facing any difficulty.
Driving online doesn't have the skills of driving
on real. A first person shooter puts you to the role of one particular character toting many
weapons along with the common goal of reaching the end, escaping doom and all sorts of that fun stuff.
In the early days in the alpha build of the game Rust's
servers were populated with zombies and every character obtained completely naked,
with fully rendered genitalia. The online horse games really are a meticulous choice of the best horse
games to match every player that lays eyes on Horse - Games.
There is the one other popular card math games
for kindergarten plus it requires 'making ten'.
Three different game difficulty, simple and medium easier to
play those beginners. Witty Dicie online educational games can certainly be
a great way to make your children learn even boring stuff and they'll even if it's just get it.

One from the operational differences between softwares is capacity to
remove protection and variety of protection types they're able to removing.
In the work, the Hong Tianlei T department are entitled to "sports work," said, the project of exquisite imagine.
Just make sure to experiment with these different forms of games yourself.

Moment, what can easily be bought in standard suggestions that generate them clear and understandable the guidelines with the routines and in addition give opportunity to implement their sensation. No matter in the
event you game for fun, learning or incorporate some
other gain in mind, hopefully you've got found this article good to your efforts.
When the next thunderstorm forecast is a similar extreme heat continuously, finding new and
fun indoor games for children will start being a good challenge.
Anybody can learn to play the this wear game in the instance, however it will require
focus and practice to completely become an expert.
"Order Chaos Online" is a true real-time, full 3D massively multiplayer online role-playing game.
One of people super-cool gizmos usually be stuck inside the
terminology. They will be in beautiful red colors
that no one other equipment is on this color. When the person decide to learn the sport games that would
be designed as cool math games games you're likely to quickly find that will these are generally rather addicting games within the market to
try out. These portals can present you with remarkable usage of the latest games that
are widely spread. This game will be the predecessor of contemporary game playing and helped to define the background in the battle space.
You could easily imagine some gallant warrior or mage heading
down inside the history books with that name. If they have wheels, also
it moves, it's about this site. With an absolutely new setting, branching dialogue trees (fully voiced), along with a host of awesome-looking character classes, The Old Republic may finally be the action that emerges
as a legitimate challenger to World of Warcraft. It's less easy as just switching it on like normal.


It's hard to find experienced

It's hard to find experienced people about this topic,
however, you sound like you know what you're talking about!


For most recent news you have

For most recent news you have to go to see web and on web I found this
site as a best web page for hottest updates.


Luxury villas in the Greek

Luxury villas in the Greek Isles really are
a dream holiday pick, not only in summer time, but also in spring as well as fall when the sun isn't so strong,
but the azure Aegean and Ionian Seas still sparkle against sandy shorelines and
reflect off pure white houses. To many, Andalucia is interchangeable with
the Costa del Sol, the aptly called sunshine shore per year with
increased hours of sun than just about any other vacation area.
Lodging merely including GBP36fee.


Your post is good. I like

Your post is good. I like style of your writing. So I got pleasure reading it. Thanks a lot!


Thatt iss really interesting,

Thatt iss really interesting, You're a very skilled blogger.
I've joined ylur feed and stay upp for searching for extra of your great post.
Also, I've shared your web site in my social networks


Good post. I will be dealing

Good post. I will be dealing with some of these issues
as well..


Its like you read my mind!

Its like you read my mind! You seem to know so much about this,
like you wrote the book in it or something.
I think that you can do with a few pics to drive the message home a little bit, but instead of that, this is
wonderful blog. A fantastic read. I'll certainly be


With havin so much written

With havin so much written content do you ever run into any issues of plagorim
or copyright violation? My site has a lot of unique content I've either authored myself or outsourced but
it looks like a lot of it is popping it up all over the web without my authorization.
Do you know any ways to help stop content from being stolen? I'd really appreciate it.


It is appropriate time to

It is appropriate time to make a few plans for the longer term and it is time to be happy.

I've read this put up and if I could I wish
to recommend you some fascinating issues or tips. Perhaps you could write next articles referring to
this article. I desire to read more issues about it!


If we can look at the things

If we can look at the things in life we regret having done, maybe we can understand that other
people are entitled to make mistakes, even when those mistakes
hurt us. It is through the facial appearance, the quality of the clothings worn, and the luminosity and
colours of the aura of the soul that the degree of evolution of
the soul may be determined. The acai berries must be
loaded into baskets and onto boats soon after picking.
It will also take away the redness and inflammation like Lavender
and Chamomile. Older people need half-dozen to fifteen micrograms of B12
each day ( the RDA is just a couple of.


You should also keep in mind

You should also keep in mind that a plant will have different branching structures throughout its growth.
Perhaps you want to do landscaping on the side and go full-time when you already have a
steady list of clients. Any business you want to start needs to begin with a business plan.


When someone writes an

When someone writes an article he/she keeps
the thought of a user in his/her brain that how a user can know it.
Thus that's why this post is perfect. Thanks!


Water: A dish of water should

Water: A dish of water should always be available for both drinking
and soaking (for smaller snakes). They are soft and
spring Mattress , Palm fiber flexibility Bed Cushion and furniture as software.

Food and Drug Administration (FDA) and the United States Department of
Agriculture (USDA) have the mandate to monitor peanuts and field corn for aflatoxin content and
have the power to mandate a recall on any food or feed that has
a high level of aflatoxins.


I have been exploring for a

I have been exploring for a little for any high quality articles or blog posts in this kind of space
. Exploring in Yahoo I eventually stumbled upon this web site.
Studying this information So i'm happy to show that I have an incredibly excellent uncanny feeling
I found out just what I needed. I such a lot for sure will make certain to don?t disregard this site and give it a look regularly.


Zgodnie z zaleceniami lekarzy

Zgodnie z zaleceniami lekarzy specjalistów onkologii klinicznej oznaczenie
CEA ma sens w monitorowaniu skuteczności leczenia systemowego (chemioterapii) u pacjentów z uogólnionym rakiem jelita grubego.


That is very kind of you to

That is very kind of you to write this share for us, thanks a lot


Hmm is anyone else

Hmm is anyone else encountering problems with the pictures on this blog loading?
I'm trying to determine if its a problem on my end or if it's the
blog. Any responses would be greatly appreciated.


Heya! I know this is kind of

Heya! I know this is kind of off-topic however I needed to ask.
Does managing a well-established blog like yours take a lot
of work? I'm brand new to blogging however I do write
in my journal every day. I'd like to start a blog so I can share my experience and feelings online.
Please let me know if you have any suggestions or tips for brand new aspiring blog owners.
Appreciate it!


I just stumbled upon your web

I just stumbled upon your web site and in accession capital to assert that I get actually enjoyed account your blog posts. You obviously can’t confront anyone about what you have discovered if the information isn’t right


I could not refrain from

I could not refrain from commenting. Well

Post new comment

The content of this field is kept private and will not be shown publicly.
By submitting this form, you accept the Mollom privacy policy.