Responsive Theming: Foundation, Bootstrap, or Omega?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
laughnan's picture

Messing around with responsive theming and was wondering...what's the best (preferred?) approach to developing a responsive Drupal 7 site?

  • Foundation?
  • Bootstrap?
  • Sub-theme Omega? [http://drupal.org/project/omega]

We've been talking about this a lot in front-end meetups and also in the Portland Drupal meetup.

Thoughts? Preferences?

Comments

Try Zen!

abelb's picture

It is probably the best responsive theme out there right now (in my opinion).
http://drupal.org/project/zen
The documentation is great and the responsiveness is built in using sass.

I have used Omega as well but I find it has a lot of overhead and admin ui. It works for certain use cases.

I've also had luck with Zen.

mpgeek's picture

I've also had luck with Zen. I've wanted to substitute Foundation's grid in for Zen to give it a try, but Zen's grid is really easy to use with SASS and makes grid config super easy. Its really easy to add Foundation elements to it, like Orbit, Tabs, Reveal, etc. If you do go with Zen, be sure to read the included docs, as it will save you hours: http://zengrids.com/help/.

Adding Foundation elements to Zen

Wanwu's picture

@mpgeek

"Its really easy to add Foundation elements to it, like Orbit, Tabs, Reveal, etc."

Phmm... How do you go about this? I've been playing around with the foundation.css and Firebug. I managed to style the "main-menu" using the Foundation nav-bar. But I'm really not sure what is the proper way to go about this?

Would be great if I could get an explanation of how to theme, for example, the main-menu of Zen5 with a Foundation component (nav-bar).

  • I need to style using MYTHEMENAME_preprocess_page in template.php? Adding in the CSS class nav-bar, right? Any sample code for the building of the render array?
  • How do I best merge the Foundation SASS files with the Zen SASS files in order to create the Foundation.css etc..? What do I need to @import, where? What should I add to config.rb, and .info file?
  • What would the overall process be in terms of, say using the Orbital JS?

Many thanks, but I am not sure how to best progress from hacking around in Firebug using the Foundation.css which I have just dumped in myzentheme/css. Clearly there must be a correct way to approach this, but I can't seem to find it easy!

Thanks in advance

PW

Foundation and Zen

mpgeek's picture

@Wanwu,

Getting Foundation to work with Drupal can be challenging, but observing some of Drupal's best-practice design patterns can help.

How do I theme the main-menu of Zen5 with the Nav Bar Foundation component? Do I need to style using MYTHEMENAME_preprocess_page in template.php ... adding in the CSS class nav-bar?

Using THEME_preprocess_page may be too far up the theme stack to be manageable (opinion)... you'd have to walk farily deep into render arrays or even--eghaads--override already-produced markup with preg_* to get at the markup your after. It's far easier to work with theme_* hooks, the associated preprocess/process functions and markup templates (*.tpl.php). We need to get involved with markup creation in the theme layer, so we don't really need render arrays (render arrays are far more useful at the module layer; another opinion). Just use Drupal's API functions for generating markup in your theme.

How do I best merge the Foundation SASS files with the Zen SASS files in order to create the Foundation.css etc..? What do I need to @import, where? What should I add to config.rb, and .info file?

When I first thougth about making a Foundation-driven Drupal theme my first knee-jerk solution was to just try to smush Zen and Foundation together in one fell swoop. What i found is that too many things break all at once, and it ended up being easier to think modular: let Zen do what it's realy good at, and utilize foundation for polish.

For project structure, I normally use Zen's config.rb, and add Foundation components to that. That is, i dont' use Foundation as the "master" project architecture, I use the STARTERKIT sturcture.

What would the overall process be in terms of, say using the Orbital JS?

Starting from scratch, first make the subtheme:

You can do this manually by reading the instructions in Zen's README, or here...
http://drupal.org/node/1549668
... You could also spin up the subtheme with Drush commands. The idea is that you should create a Zen sub theme and do all of your work there, overriding Zen per-opportunity. This gives you a blank-slate wroking area that doesn't destroy your upgrade path for Zen.

Having the playground ready, generally speaking, for any given component you need to ...
1. Add the JS (jquery.foundation.COMPONENT.js) to your theme, and refer to it in your theme's info file.
2. Add the corresponding CSS to your theme, and refer to it in your theme's info file.
3. Utilize theme hooks in template.php and optionally write preprocess/process functions in the theme layer to produce markup that the Foundation components are expecting.

Applying this to Foundation Orbit...

  1. Spin up the subtheme
  2. Generate Orbit-friendly markup with field_collections of images, or just a multiple-valued image fields.
  3. Either create a view and associated templates to get the markup you need (hard), or use field_orbit (http://drupal.org/project/field_orbit) (EASY). Field Orbit gives you a display formatter that produces the markup automagically.
  4. Add the Orbit SASS to your project, and refer to the generated CSS in your theme's info file
  5. Add the Orbit JS to the theme and refer to it in your info file.
  6. Do any needed modification of HTML output with preprocess/process/tpl functions and files.

This has worked pretty well in the past. However, I haven't yet had a chance to try the Foundation grid in place of the Zen grid. I did find some documentation for swapping out the grid framework, but I haven't found a use case where using the Zen grid with Foundation elements wasn't enough.

Re: Foundation and Zen

Wanwu's picture

@mpgeek

Thanks for a great breakdown of your process and heads-up on how to approach this.

It makes sense - just need to get a handle on it all as theming is new to me.

Once I've gone through integration, maybe there could be new thread on this topic? Am sure there are a lot of people who are wanting to, as you nicely put it:

"let Zen do what it's realy good at, and utilize foundation for polish."

So the process as I see it:
1. Create sub theme of Zen
2. Add JS and SASS to sub-theme and refer to both .js and generated .css inside .info file of sub theme
3. Create markup for either the JS and/or styling using theme_hooks/pre&post process/tpl files

One things I just am not sure about is the config.rb file:

"For project structure, I normally use Zen's config.rb, and add Foundation components to that."

  • Not quite sure what needs to 'go in' config.rb?
  • Do I need to add 'require zurb-foundation' ? Actually, what does this line do!?
  • Ditto: what does @import "foundation/navbar" do?

[ I notice these in the Zurb config.rb & in navbar.scss ]

Many thanks

@Wanwu, In a nuthshell

mpgeek's picture

@Wanwu, In a nuthshell config.rb sets up the structure of your SASS project, and the references to Zurb resources are importing the Foundation elements as SASS plugins into your project. You want to use/extend Zen's config.rb to set up the subtheme, and import/require Foundation elements into it.

In any case, it sounds like you might benefit by taking a deep breath and spending a few minutes with the documentation...

If you are new to Drupal theming, try the D6/7 theming guide:
http://drupal.org/theme-guide/6-7

Zen's documentation is great, and you can learn a lot in 20 minutes:
http://drupal.org/node/193318

Configuring your SASS project:
http://compass-style.org/help/tutorials/configuration-reference/
... in fact, the whole tutorial section there is great, but the above link covers config.rb.

Once you get the hang of the workflow, you'll be surprised how fast and easy it actually is.

Good luck.

Links

Wanwu's picture

@mpgeek

Thanks a ton for the links.

Some good stuff on drupal I hadn't come across. And the compass documenation look excellent as does the Zen documentation.

Many thanks for your time & guidance.

Wondering the same thing

chrsnlsn's picture

I am currently working on a project that I went with bootstrap for, just because I have used it recently for a couple non-drupal sites and the drupal theme was a really simple layout. I would definitely be interested in hearing pros / cons of the other options though.

I'll cast a vote for an Omega

floydm's picture

I'll cast a vote for an Omega subtheme (use the omega_tools module) with SASS+Compass. Follow these steps to get up and running:

http://groups.drupal.org/node/206148#comment-683073

Omega does have a learning curve but it is pretty awesome when you figure out what is going on. Lots of other folks are using it too, so it is pretty easy to find the answers to any questions you have.

Good luck!

-Floyd

At Cheeky Monkey we have

gbernier's picture

At Cheeky Monkey we have adopted using Omega pretty much exclusively as well. Like Floydm says, it's pretty powerful once you get wrapped around delta's context and having omega tools installed

Gene

Boots

mpgeek's picture

There's also Boots (http://drupal.org/project/boots), which is Tiles-ready (http://drupal.org/project/tiles). Boots is an implementation of Twitter's Bootstrap, and Tiles gives you an easy and lightweight way to let users to manage their layouts without getting all wrapped up in blocks config or Context. I haven't tried it, but it's probably worth a look.

I prefer Zen subtheming because SASS is better than sliced bread, and with a Zen subtheme i can export my theme settings and Contexts (http://drupal.org/project/context) to Features and deploy it just like any other Feature. Not sure how that works for other stacks, but that's what works for me.

Omega 4 & Foundation, anyone?

PeterEmil's picture

Last year I joined the Drupal bandwagon. Worked on WordPress/Contao/ModX powered sites and was warned about the steep learning curve of Drupal. Looked at Omega but 3.x is too bloated. I opted for Zen 3.x with Zengrids. Meanwhile I played happily with Sass and Susy. In plain HTML it is super-easy to get a library like Foundation or Bootstrap working. But Drupal isn't straight forward in my opinion. I hope I'm wrong, because the next year I'll be working a lot with Drupal and WordPress side-by-side.

Like mpgeek I squashed Zen together with Sass-Bootstrap; Zen for the heavy Drupal lifting and Bootstrap for the polish. But mixins from BS & Compass were clashing frequently. Now I have a certain workflow with Zen, but Zengrids has some quirky elements I've never ironed out.

Now Omega has dropped its bloated backend fluff and is focusing on D8 & SMACSS, together with Susy for its grid system I really feel the need to check this out. Why? Because ZURB_Foundation / Foundation7 / Zoundation themes gives Foundation but aren' user friendly; In ZURB_Foundation I simply can't get a top-bar navigation. Issues with solutions & patches are flying round like a circus-goat but that's not what I want; I want a clean slate which is concise and pragmatic in it's workflow.

Anyone uses Omega 4 in conjunction with Foundation or Bootstrap for the polish? Like to read your findings!

Not trying to derail here but

jgraham's picture

Not trying to derail here but Zoundation along with the Zoundation Support module(s) provide a custom top bar region with block menus that create Foundation friendly markup for inclusion in the topbar region. This has worked really well for us. The support module also provides several useful theme helpers that can be called programatically to do things like having node dropdown in a button with one click or having single button or split button menus.

Curious what you find is not "user friendly" about zoundation and if it's anything we could address?