Creating flexible news page layouts with Panels2

Events happening in the community are now at Drupal community events on www.drupal.org.
yelvington's picture

I'm a latecomer to the Panels party. We've been able to use blocks and regions to accommodate our layout needs for our community websites. But as we work on a project to launch two large newspapers on Drupal later this year, we're looking for ways to enable editors to create and manage special page layouts on the fly, as the changing news demands.

That led to Panels, and after spending some time with Panels 2, I'm blown away.

Here's how Panels solves the problem.

Take a look at the layout at right. It's fairly typical of a wireframe for a homepage or section front on a news site, with a header, footer, 300-pixel standard ad stack on the right, and a bunch of varied blocks in the core of the page.

With a conventional approach, you'd break the page into regions, drop blocks into those regions, and be done with it.

To achieve flexibility, you might create multiple layouts and dynamically switch among them by setting a system variable, but you'll run into a hardwired problem with Drupal: Blocks belong to one, and only one, named region. If a variant page layout needs to change the mix, you're stuck.

Panels provides grids that can be dropped into the page core -- the $content variable in page.tpl.php -- that can pull in a mix of node, block, view and arbitrary custom content.

But with Panels 1, you're limited to a fixed set of grids, and they could not hit the target in this wireframe because of the odd spacing you see in the cell toward the top of the content area. You can add grids to your own specifications, but it requires some programming work.

Panels 2 breaks through this barrier by adding yet another layer -- mini panels. A mini panel is just like a regular panel, except for two things: it can be placed inside a regular panel (just like node, block, view and arbitrary content), and you're not limited to the standard provided grids.

Want one, two, three, four rows? Different numbers of columns in each row? Arbitrary widths per column? No problem. No HTML, no CSS, no coding. Just fill out the form.

Now you're cooking.

Panels also lets you designate which blocks and views will be available to editors, solving the "omigod that's cluttered" problem of the admin/build/blocks page. You don't need "administer blocks" privileges to manage panels, either.

And Panels 2 adds a bit of Jquery drag-and-drop goodness to the user interface. Components can be dragged from one cell to another within a grid. They can be temporarily hidden without removing them. And if there's a need to reconfigure a block, that's can be one click away, too.

So Panels 2 neatly solves our flexibility problem. And in doing so, it actually simplifies our site theme development work as well, because a single page template can serve a multitude of needs that otherwise might have required a series of related templates. This will lower our theme HTML/CSS coding costs.

There's one more, unexpected benefit of Panels: It dovetails nicely with a dayparting module we've been developing.

Our dayparting module, originally written by Mike Napier of the Topeka Capital-Journal, will manage a daypart schedule. At configurable points during the 24-hour cycle, it can automatically switch from one prepared homepage layout to another by changing the Drupal front page system variable. Because it will work with Panels pages, editors will be able to tinker and polish the layouts in advance, even preparing arbitrary new presentations for special projects and special days.

We'll be releasing the dayparting module under the GPL soon. We hope to also create some abstracted page templates and eventually an installation profile script that will automate some of the tedious configuration steps associated with building a newspaper website.

Comments

why?

dan_k's picture

I appreciate the info, but why not just use expression engine, wordpress, joomla 1.5 (with its MVC) or bricolage for projects like this? Your workload would drop off immensely, and a lay person might have a hope of being able to learn how to change the layout, possibly without leaving the admin UI.

That's my dilemma. Other things in Drupal appeal, but when it comes to complex layout/design...I look elsewhere. Not because it can't be done but because it's a much harder, longer process.

Dan Knauss

LinkedIn: www.linkedin.com/in/danknauss
New Local Media :: www.newlocalmedia.com

I do not find Drupal's

grndlvl's picture

I do not find Drupal's phptemplate any harder or more time consuming than either WordPress or Joomla 1.5 they are about the same for the most part, Joomla still has some ways to go with its MVC, most of the third party modules do not support the MVC structure as core does. Not to mention I am not aware of either WordPress or Joomla 1.5 allowing full customization from the interface like panels offers Drupal, I think that panels is finally the answer for editors to edit their front pages on the demand without the knowing even the simplest of HTML. Although, only time will tell on this subject.

I am unable to state an opinion about Expression Engine I have not used it so...

A much longer list of requirements

yelvington's picture

Those other systems wouldn't address our other requirements, which run to many pages of detail and encompass social networking, content aggregation, community groups, notifications, et cetera, et cetera, without a great deal of development work and hair-pulling that's not necessary with Drupal. We currently have Wordpress and Joomla installations for situations in which they are appropriate. This isn't one of them.

And if you didn't get the main point here: A lay person DOES have the ability to change the layout. Editors won't have to know a thing about HTML or CSS.

not seeing it

dan_k's picture

Nope, I didn't get that panels lets you change the layout without any php or html/css knowledge. Very nice.

The others systems I mentioned--Joomla and EE--would indeed address all of the requirements you list, except Wordpress, which is tough to use to build out a community site and has the most limited ACL. I don't know if EE's member manager extension is as robust as the Drupal ACL. Joomla's is not and was never intended to be. You have a number of options to change that, however.

But I am increasingly wondering about the wisdom of trying to make a CMS double as a social network with forums and so forth. Even with Drupal it creates a lot of 3rd party extension based breaking points that are vulnerable to exploits and failure during upgrades. It might make a lot of sense to use a separate platform for the social features with some kind of bridging system along the lines of the jFusion extension for Joomla. This might result in lower maintenance and the unlikelihood of the whole site going down.

Dan Knauss

LinkedIn: www.linkedin.com/in/danknauss
New Local Media :: www.newlocalmedia.com

Post Fix

grndlvl's picture

You have Mike Napier of the Topeka Capital-Journal down as the only contributor fo the daypart module for Morris when in fact there was a complete rewrite of the module which included Craig Sims from Jacksonville Florida and myself.

Just thought I would throw that in there.

Noted

yelvington's picture

I changed it to "originally."

For everybody else's benefit: Since grndlvl (Jonathan Delaigle) is running away from home -- leaving Morris Digital Works! -- we had him locked in a conference room for a couple of days with several other folks, teaching a Drupal module development and theming workshop. They picked apart Mike's module and put it back together again, and when all was said and done, I think everybody emerged with a thorough understanding of the forms API. Jonathan did a great job, although his phone kept buzzing. :-)

Another couple of benefits

merlinofchaos's picture

Let me add a couple of other points to Panels that take a little longer to really get:

1) It's actually very easy to create customized layouts. For one, the 'flexible' layout creator lets you do it with just UI, but for two, if you can design the HTML and CSS necessary to do your very complex layouts, then the plugin to add that in is not too difficult to write. (Sidenote. I wish you could put these plugins in themes, but Drupal's theme layer makes that difficult).

2) There's actually two applications that run Panels pages -- there's the 'page' part, that gives it the URL and figures out all the context stuff, and there's the 'display' part (panels.module) that handles the layout and content arranging. The reason this is important is that you can actually create a module to do away with panels pages and simplify it to just your needs quite easily. This is how og_panels works (which is in use on this site) -- so that you can have panels that are easily added to an organic group. Likewise, mini panels, really, are another example of how you can do this same thing. This means it requires a little dev time up front, but but doing so you can tailor your UI to your site or package's needs and reduce the load on the people who will actually be managing the site.

Great job

yelvington's picture

Great job, Earl.

Very interested

ken hawkins's picture

We had originally played around with panels to do our site, but as the homepage was the only page we needed to do anything too fancy with, we just hard-coded node_loads and build_views into page-front.tpl -- but we're outgrowing that solution, and if we can start scheduling new layouts to post, I'll be very interested.

Think there's any simple way the different versions could be archived (i.e. page one from 2008-08-17 11 a.m., page one from 2008-08-17 4 p.m., etc)?

So, the concrete answer: a

sdboyer's picture

So, the concrete answer: a system somewhat similar to the one you're describing here is being used for http://socialistworker.org, and it didn't take that much work to get it set up, from what dww has said.

The more abstract, pimp-the-module answer: ABSOLUTELY! Nothing via the UI - but my general estimation is that you could accomplish precisely that effect in a custom module of around 500 lines. A big UI would make it longer, of course, but the bottom line is that Panels is abstracted to the point where you're able to lay pretty much any when/why/which/where logic you want on top callbacks that edit/build and render panels.

Newspapers on Drupal

Group organizers

Group categories

Topics - Newspaper on Drupal

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: