One Drupal Themers Path for Defining a New Panel

My goal is to continue my work exploring the 960 grid system. I ‘mostly’ like the mark-up, and I really like the visual representation. The classes and id’s seem to fit my style. I have an awesome “Mothership” (morten), and developing some very cool subthemes for a client that will allow them some incredible flexibility and the ability to add new themes (colors, images, shapes) pretty quickly without losing the overall look and feel...

Anyway…
My next evolution was to use 960.gs with panels. I love the flexibility and flow of panels so now I need to create my own panel with specific mark-up for 960.gs, and so that it will fit into my “Mothership”. At the time of this blog post I am using Panels 6.0-3-alpha4. My plan is to create a 3 panel layout that is large, medium, and small. For 960.gs using the 12 grid, I am creating a grid_5, grid_4, and grid_3. Here we go…

Finding Nemo (tpl files)

As a themer I feel very fortunate that merlinofchaos uses timplefifs (morten) almost as a philosophy. I found the files I wanted to work /panels/plugins/layouts

This is my first go at this, so I didn’t want to fuss with the flexible layout, and I didn’t want to add or guess at any extra variables, so I decide to start with one of the three column layouts (threecol_25_50_25)

My First Path

I copied all of the files into a new folder called panelcool
[inline:copyfolder.png]

I renamed the files.
[inline:renamebefore.png]
[inline:renameafter.png]

Then I dug right into what I know best first… the tpl file, and here is where I make my mark-up changes, the new code looks like this.

>

 
 



Now it’s time to suck it up and work with the function. The function can be found in the renamed file (panelcool.inc) here is the BEFORE and AFTER…

BEFORE


function panels_threecol_25_50_25_panels_layouts() {
$items['threecol_25_50_25'] = array(
'title' => t('Three column 25/50/25'),
'icon' => 'threecol_25_50_25.png',
'theme' => 'panels_threecol_25_50_25',
'theme arguments' => array('id', 'content'),
'panels' => array(
'left' => t('Left side'),
'middle' => t('Middle column'),
'right' => t('Right side')
),
);

return $items;
}


AFTER


function panels_panelcool_panels_layouts() {
$items['panelcool'] = array(
'title' => t('Panel Cool'),
'icon' => 'panelcool.png',
'theme' => 'panelcool',
'theme arguments' => array('id', 'content'),
'panels' => array(
'left' => t('Left side'),
'middle' => t('Middle column'),
'right' => t('Right side')
),
);

return $items;
}


Optional Stuff

I changed the png image so I could see the changes :)
I didn’t mess with the css for this because the 960.gs css is already in my theme, so the layout will be controlled by that file, but if you want to add the css file add 'css'=> 'panelcool.css', to the array $items['panelcool'] = array(, that will get it loading for you.

Head back to a panel layout screen and BAMO!
[inline:hereitis1.png]
[inline:panelsin543.png]

Next week we’ll make our new Panel into a module so we don’t hack Panels2 by leaving our directory in there… it’s in alpha after all, we don’t want to move and replace the file every time.

Comments

16

just about 60 seconds, and you'll spend most of it on the .info file =) just implement the directories hook, tell it what directory you want your layouts in and copy your layout directory over to your module. Finis. Or stick it in your theme, if you like. That's barely documented so far, but your theme can provide layouts too.

just implement the directories hook, tell it what directory you want your layouts in and copy your layout directory over to your module. Finis.

I've actually created a module that provides a few new layouts without messing around with files in the Panels module – it is, however, for Panels 3, but feel free to take a look: http://github.com/kdb/bibliotek.kk.dk/tree/4a4494273ea92c921be46d9fe008735c2215a967/sites/all/modules/library_panels_layouts

Can you provide another link for this? Thanks in advance.

Added to <a href="http://DrupalSightings.com">DrupalSightings.com</a>

This is really cool and would be even cooler if it could be wrapped into a module so that panels wouldnt need to be hacked... Is the process for this the same with panels 3? really looking for the right way to do this and it feels like you are so going in the right direction great article, thanks

I am using Drupal two years and I love it.Great tutorial.

nice alternative to define a new panel ...

I am not much into reading, but somehow I got to read nice information on your site. Simple to understand and helpful. We will look forward for your future updates. Thanks

I like to push the boundaries. I love creating unique, clean, usable design for the web and other digital sources. Now I am doing <a href="http://www.ccnaexamquestions.com">ccna</a> for better job.

I always try to find tutorials on Drupal & I find this article good one to learn something about Drupal.In few days I've learned a lot about Drupal through many blogs.I must appreciate you for this information.Thanks. Bijaya, <a href="http://www.smallstorageboxesreview.com/">Small Storage Boxes</a>

A user with sufficient permission can define new roles for your site, create new user accounts, and assign different permissions to the roles; the screens to manage users and roles can be found at path "admin/user".

The key features for using Drupal development are it is ease-of-use and large selection of modules and themes.

I love this new module. This is really cool and would be even cooler. Is the process for this the same with panels 3? really looking for the right way to do this and it feels like you are so going in the right direction. [url=http://www.esleepmasters.com/Ellipticals_s/2315.htm]elliptical machine[/url]

thanks for your post...nice nice post

It’s really great post. I would like to appreciate your work and would like to tell to my friends. Thanks for sharing!!Please click here http://sonnerieportablegratuit.com