Panels 2.0 design

After giving this a great deal of thought, I have worked up a preliminary design for Panels 2.0. My primary design goal with this is flexibility, so that panels can be used in a variety of situations. The example situations I have come up with are the following:

  • Panel as a page (this is what we currently have)
  • Panel as a node -- some have mentioned missing this feature from the dashboard days.
  • Panel as a framework for a node
  • Panel as a framework for a page
  • Panel as a framework for an organic group
  • Panel as a framework for a user / user's 'homepage'.
  • Panel as a framework for a user's blog

The first step in doing this is to break the existing panels module into two parts. The first part is the core panels.module, which will exist only as an API. The second part is the panels-page, which will probably be in the same module as it should not be a very large amount of code and is probably always useful.

The core panels API

  • Provide a 'panel' object which consists essentially of just the basic layout plus the content that's in it.
  • Load a panel object using a panel ID. Optionally named panels like Views but I haven't convinced myself this is necessary or a good idea.
  • Provide UI to edit a loaded panel object
  • Save a panel object
  • Provide methods to load content into the editor.
  • Provide methods to display the panel.

The panels-page module:

  • Provide URL, menu items and access control to pages
  • Link these pages to a panel
  • Load all available content into the panel editor
  • Display the linked panel within the page.
  • To accomplish this, page specific fields such as URL will be removed from the panels table and moved into a panels_page (or along that lines) table. Also, the block content type needs to be improved to support all existing block controls such as access control and url based filtering, plus supporting the block configuration mechanism (even if that configuration is global and not on a per panel basis unfortunately).

Once this is accomplished, we can start to fill out the above list.

The panels-node module:

  • Provide a node type and/or CCK field that is a panel
  • Load all available content into the panel editor and edit the panel during node edit.
  • Display the linked panel within node view.

To go on with the rest of these, however, we need to do a little more to the
basic panel system. It needs a new content type, a type that is Panels aware.

The panel_content type:

  • Is aware of panels and can take advantage of data that it may be preloaded with, such as URL arguments (can enhance panels-page), or some other data such as the current node or current user/node author.
  • Can be provided globally or only used locally (i.e, provided to the editor only by modules that are aware of its existence).
  • Panels itself would include, at the very least, the 'main content' content block which represents the primary content that is passed into the panel. This could be a node or a user profile, or even an entire page.

For example, the panels_og module could:

  • Provide a bunch of panels_content types that are specific to groups, such as a series of views that follow a certain naming convention, plus other non-view content such as a list of group members, a group control block,
  • Provides a method for the administrator of a group to attach a panel to the group and edit it.
  • Displays that panel for the group node; uses that (or maybe a different) panel as the framework for nodes that are in the group. Using a choice of panels here would be wise; perhaps forum posts use a slightly different framework than event nodes.
  • Sets the group or node being viewed as the 'main content' and requires the main content panel_content to be placed within the panel object once and only once.

For example, the panels_node_framework module could:

  • Provide panel_content that is specific to a node. Examples might be the prototypical profile block, related nodes, views that use 'nid' as the only required argument. Allows for other modules to specify that their panel content is suitable for the node framework (this would work really well for voting widgets and ecommerce widgets).
  • Hook into the node view system to encapsulate the node as the main_content portion of the panel and display the panel.
  • Allow the panel to be used to be selected by some combination of node type and/or taxonomy term.

For example, the panels_page_framework module could:

  • Provide all block and panel content to the panel editor
  • Provide a method to choose a panel based upon URL and/or some other criteria I haven't thought about.
  • Hook into the page view to encapsulate a page as the main_content of the panel.

For example, the panels_my_blog module could:

  • Provide content specific to users; allow other modules to specify their panel content as suitable for this module. Great examples are the profile block, recent comments on my posts view, etc.
  • Allow users to create panels that be attached to their blog/home page and used as an overlay on their blog nodes.

In terms of implementation details, the panel_content is probably the hardest part to design right. The content needs to be flexible; it needs to be able to specify where it can be used, which means we need to identify as many obvious uses as possible and hope that we cover enough bases that similar uses can simply choose one of the options. I'm thinking a hook to discover content types that returns an id and enough information; and another hook that takes that id, the panel info and can then provide the content. I don't want to have to cache this data like we do in Views; I think this is feasible since we really only need the whole list of content during the edit phase. The id should be enough for the content render function to figure out what it needs to
do.

At this point, I ask for commentary!

Rock on

I have truly appreciated that Panels operates as a page, not a node, as I generally have used the module to create user-admin changeable presentations of content, not content itself. (It's a wonderful companion to the views module.) I did not like it when presentation pages would show up in the popular content lists, for example.

However, your post really offers some fascinating and interesting ideas about how Panels might be useful in a lot of ways.

Where I can see much additional use of panels would be in the og area, and with user profiles.

Great work!

This really warms my heart.

This really warms my heart. Views really revolutionized Drupal (for me, anyway) and Panels 2.0 is set to take it a step further (it's already great but limited for large sites). Here are my two scenarios:

1. I need very complex user homepages but I also need to categorize users in many different ways so that the profile module is not sufficient for my needs. I would like to use Panels to pull in all sorts of data but I would like a Panel to be generated automatically for each user. So I would set up a panels node type as the usernode and then I would have to pass the argument from Panels to individual Views.

2. I use OG for research groups on my site but I also need them to function as outward facing front pages for which OG is not very well suited. Panels 2.0 would solve that problem.

There are two features from Views that might make Panels 2.0 even better: import/export and theme wizard. But these are just nice, not essential.

Anyway, thanks for your hard work.

You are the man.

Just wanted to give some props. Views & Panels are by far the most powerful modules for me in drupal. They have saved me buttloads of time!

Change layout

It would be nice if we could change the panel layout without loosing it's contents. But I guess it would require a separation between contents and layout.
Typical case:
Client: "Oh yeah we need to add this text/banner at the bottom" or "We need a third column on the left for the quotes" "Oh no, after all we don't need the banner anymore".
With Panels 1 it means you have to create a new Panel and re-select all the content-parts everytime.

But then what would happen if you switch from a 3-areas Panel to a 2-areas one? Your three blocks of contents would be still displayed, but would need to be "moved" to one of the existing template's area.
Or it may be something like adding a "Move to..." select in the "Configure" tab of every content, so you could move it to another area.
Oh no wait, just add a drag n'drop feature with jQuery :) What do you mean "Easier said than done" ?

Yea. The main reason I

Yea. The main reason I didn't create any way to do this was the complexity of transferring the content. I suppose it could work if change layout presented an additional screen, listing all of the content areas of the current layout and each one had a select box with all the content areas of the new layout and it could transfer. That makes it a multi step process, but in 5.0 the multi step processes are much easier.

And I definitely want to have the drag & drop stuff in the 2.0 version. Ayman has already done some work on that (check out http://test.logrus.com/dnd_test which is an early early demo -- doesn't yet work in Safari or Opera) and it's enough to prove the concept.

I'll keep this stuff in mind. The editor itself is a lot better than what we've had before but definitely needs improvements. Also the drag & drop stuff has a problem with degradation, but honestly so does the existing panel editor since all of the fieldsets spring open in a manner that isn't conducive to actually using it.

Edit button in content

I've found that users sometimes have a hard time finding where to edit the panel's contents. To them the easiest way would be to have an "Edit" button at the top of every content-part (if their user access allows it of course).
It's not a big problem with links lists because you can click on a link, then click edit. But for custom content you have to use the panels admin page.

Another case here: http://www.continentalmag.info/sommaire
Except for the top left "box" which is made with views, I used regular nodes without their title because they are not supposed to be browsed as single pages. But there is no quick and obvious way to edit these nodes, the editor has go to the nodes list and remember which ones he needs to edit.

Apart from this it's a great module and the upcoming features seem very promising!

Actually, this isn't really

Actually, this isn't really so much an issue for panels as it's an issue for theming.

Panels, really, is just running things through node_view() -- which means you actually have pretty much ultimate flexibility. I suggest something like this somewhere in your node.tpl.php or node-TYPE.tpl.php

<?php

if (!$page && node_access('update', $node)) {
  print
l('edit', "node/$node->nid/edit");
}
?>

You may want to find a way to limit it to just the nodes you're using, which is why using only a specific node type or maybe a specific taxonomy tag so that you can check that as well. Then again, it may be convenient to always have that edit link available. There are times where I really want it!

Oh, nice!

Thanks for the tip! I'll try it soon, if I can make this work I'll have a happy client

Pass-through arguments

One use case I see for panels in both a project I'm actively working on now and one I'm working on in bits and pieces is the ability to "pass through" arguments to a view or block that it contains.

For instance, I want to build an og node-browser. Think of the typical 3-panel email client. In one panel region, show all nodes of a given type in a specified og with a view. In another, show either nothing or one specific node from that list. The path would be something like: group/$oid/list/$nid, with the $oid passing through to the first view (and maybe other parameters as well) and the $nid being passed through to the second pane. (Then add CSS to taste.) That allows for a single point of configuration for a potentially large number of displays. Great for use as a web app.

I don't know how to or if I can pass-through arguments like that in the current panels. Is that something that can be done now that I'm just missing, or is that something that could be done in a straightforward manner with "Panels 2"?

Right now, panels *can* pass

Right now, panels *can* pass arguments through to Views, it's not even terribly difficult though it's not the most straightforward. But in the configure fieldset of a view in a panel, you can set the 'arguments' string, and by using %X where X is a numbered piece of the URL, you can pass that along to a view.

Blocks cannot accept arguments in their current form, so there is little that can be done there. That's why there needs to be a panel content that can be aware that panels might have data for them.

Width

One more thing. You mentioned in Brussels that one of the things you were thinking about was having panels take over the whole page including the block regions. I think this could be a really nice option in some contexts.

Indeed, the 'panels as a

Indeed, the 'panels as a page framework' essentially replaces blocks entirely.

Hey Merlin, I echo some of

Hey Merlin,

I echo some of the comments here. Views and panels are really enabling me to use Drupal.. thanks a lot for all the hardwork and if and when my site is launched and grown, I do look forward to put your creation into more and more work..

One thing i do want to let you know - i liked the new features you are proposing - however, i see it myself and on the based on drupal message boards - that both views and panels still have corner cases where they are breaking apart. I would (and i am sure many in drupal user community will) much appreciate if you are able to fix some of the common issues (like Internet explorer showing different behaviour with panels.. etc.) before you move on to the next version.

thanks a lot.

nilam

Panel as a block?

How about having ability to define a panel as a block?
For example: Let's say I have a 3 column zen theme, and in the Content-Top area I want to display two blocks side by side. Panels can already display two blocks side by side, but how can I make the panel display on every page in the content-top region?

panels as a block

Hi,

This module is allready available.
http://drupal.org/project/panelsblock

Greetings,
Martijn

Post new comment

The content of this field is kept private and will not be shown publicly.