Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture...

27
Moving stuff around on your Drupal web pages Alex Bergin / @ alexbergin Dept. Agriculture & Food @drupalwa

Transcript of Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture...

Page 1: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

Moving stuff around on your Drupal web pages

Alex Bergin / @alexberginDept. Agriculture & Food

@drupalwa

Page 2: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

Background

• Websites are dynamic that’s why we’re here, that’s why we use Drupal.

• Not all pages will want to look the same

@drupalwa

Page 3: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

Scenarios

• Websites may have:– Homepage presenting a dashboard of content.– Content Pages: Basic pages, products, events, etc.– Index taxonomy term pages, landing pages.– Search results, sitemaps.– User profile pages.– And more!

• All of which may have different layouts.

Page 4: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

SO HOW DO WE DO THIS IN DRUPAL?

Page 5: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

Blocks

Page 6: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

Blocks

• Baked into Drupal core since 4.x.• Manage blocks in your themes regions.• Suited for basic brochure sites.• Problem: dozens of blocks for dozens of

regions, not enabled for all pages?• Problem: visibility conditions limited. Php in

db bad mkay.

Page 7: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

Options

• Various contributed modules make layout management easier:1. Panels: http://drupal.org/project/panels2. Context: http://drupal.org/project/context3. Display Suite: http://drupal.org/project/ds

We’ll try go over each of these.

Page 8: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

What do they basically do though

Everything on the page

Or, all theme’s body content region

So you can use these modules in conjunction with Blocks and your theme regions, if you want to.Additionally, these things modules can use block content defined by other custom modules, themselves too

Or perhaps only node content

Page 9: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

1. Panels Module

Screenshot courtesy of themonthly.com.au

Page 10: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

1. Panels explained

• By the same legend as the Views module – Earl Miles (aka merlinofchaos). Since D4.7.

• Dependant on Ctools which includes the Page Manager module that is kind of required to use Panels.

• Panels module includes several modules: Panels, Mini Panels, Panel Nodes, and In-Place Panel Editor.

Page 11: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

1. Panels explained. More..• Panels is path driven. So a panel object exists for nodes, node

edit forms, search, etc.

@drupalwa

Page 12: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

Panels has its own terminology

• Of each panel, you have Variants, which each let you have different layouts, e.g. One for each content type.

• Each Variant can have a Layout set. Use built in panels layouts or write custom layout.

Page 13: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

Panels has its own terminology

• Selection Rules, lets you define conditions in your Variants, e.g. Different layout for a different node content type.

• Contexts – allows you to draw on other material: content, views, etc. i.e. Product panel variant bring postage conditions node into context. Not to be confused with context module.

Page 14: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

More on Panels

• Panels designed to be very extendable and powerful.

• Advanced plugin system via ctools for custom access controls, layouts, content blocks (content types), and block styles.

• Modules that extend Panels:– Panels Everywhere– Panelizer – like panel_node module

Page 15: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

2. Context

Page 16: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

2. Context

• Around since D5.x, fairly mature.• Comes with Context, Context Layouts, Context

UI. • Create contexts by specifying conditions and

then the reactions – be it blocks to show in a region.

• No field support though.

Page 17: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

2. More on Context

• Relatively easy interface to manage.• Addons for Context:– http://drupal.org/project/context_node - lets the

content creator select which context to use for their node.

– http://drupal.org/project/context_by_node - automatically creates a context when the node is created (no official 7.x version available though).

Page 18: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

3. Display Suite (DS)

Page 19: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

3. Display Suite

• Stable. Relatively new. Still catching on.• Specially built for Drupal 7 Entities: nodes,

users, terms, etc.• Layouts – includes common layouts, but easy

to create new layouts by drush instead of manually.

• View modes. i.e. Event has a full, teaser and monthly calendar view.

Page 20: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

3. Display Suite

• “Disable drupal blocks/regions” setting.• DS Custom Fields (not content fields) lets you

create more flexible fields:– Code field - meta tags, tokens, php field. – Dynamic field – kind of like panels context.– Block field - how you add other module blocks

“block fields”.– Preprocess fields – possibly lets other modules

populate them? Haven’t used this myself.

Page 21: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

3. Display Suite – Advanced Stuff

• Integration with panels layout manager.• Integration with Views Displays.• Re: Custom layouts with Drush, look for the

“ds-build” argument in Drush help.• Very decent screencasts here:

http://bit.ly/ds-d7

Page 22: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

So what to use then?

• Based on Number of Installs:1. Panels: 120,0002. Context: 65,0003. Display Suite (DS): 30,000

All growing, but DS growing the fastest.

Page 23: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

So, what to use?

• Depends on your circumstances.– Basic Brochure site – blocks– For larger sites though:• Panels is probably the most powerful, but has a steep

learning curve.• Context is probably the easiest of the lot to learn but

still requires templating for laying out field content.• Display Suite looks like it has a good balance of

usability, and power. Probably the most exciting.

Page 24: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

What to use, Continued..

• All are Exportable to features.

• One way or another it’s probably possible to do anything in any of the layout modules.

Page 25: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

Further Info

• Blocks vs. Context vs. Panels: http://www.lullabot.com/articles/assembling-pages-with-drupal

• Comparison of Layout Editors: http://groups.drupal.org/node/15851

• DS vs. Panels: http://www.jyvesgarden.com/blog/display-suite-vs-panels

• Great DS instructional videos: http://bit.ly/ds-d7

Page 26: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

What’s ahead

• Drupal 8 Initiatives: “Concept Model”• Thomas, Sam, anyone read up on this, please

share?• D8 discussions on the topic is found here:

http://groups.drupal.org/node/227543

Page 27: Moving stuff around on your Drupal web pages Alex Bergin / @alexbergin@alexbergin Dept. Agriculture & Food @drupalwa.

@drupalwa

Cheers to Thomas for organising these meetups month in month out!