Is there a decent tutorial on converting themes from 6 to 7 yet? Google's not turning up anything substantive for me.

There's the Converting 6.x themes to 7.x page, of course. I bet you could learn what you need to know from it, provided you have enough time to read and comprehend 22 pages of densely written text arranged in an apparently haphazard order bearing no relationship to the sequence of steps involved in actually converting a theme. It's not really a guide; more of a changelog.

I may well write one myself if I can figure out how to do it, but if somebody's already gotten a start someplace a link would be helpful. Thanks.

Comments

Jeff Burnz’s picture

There is a "Theming Drupal 7" handbook page underway but I am not sure if it includes updating from 6.x.

In any case the changelog you link to is not as bad as you make out, when you do your update just work through it one thing at a time, the changes are so massive its going to be a huge job to write an upgrade guide, you could do it but it will be very generic, eg:

- Update your info tile

- Split logic accross process and preprocess functions

- Update all your templates to support granular theming - pay special attention to the new templates such as html.tpl.php, and the new page.tpl.php structure

- Be aware of RDFa and the stuff you need in templates to support it

- Conditional stylesheets are supported by drupal_add_css, which is pretty cool (see Bartik for an example)

- You can do alters in template.php, so where you built a module for hook_whatever_alter you can shift this into the theme

- For API functions double check they still exist or changes, especially parameters

- For CSS there are many new classes and much bette core CSS organization, things have improved here

Theres probably more general guidelines but thats all I can think of right now.

wdmartin’s picture

Thank you, that's helpful. In particular, the update guide doesn't explain that html.tpl.php is a new template file containing the basic html/head/body parts of the structure. And I'm still not clear on what the new page.tpl.php structure is.

One question I have is -- what's with this render() function? The code for Bartik and Garland are full of calls to it, and most of the variable names I got used to working with in 6 seem to have been changed to make them array indices that get run through render(). Is there a list somewhere giving mappings of the old variable names to the new ones? I'm studying the code for Garland and Bartik to get an idea of what happened, but it's slow going.

My general impression is that D7 template files require a lot more PHP than those in D6. I can handle that, but it's disappointing; one of the things I really liked about theming in D6 was that markup and application logic were pretty strictly separated. Printing a variable (<?php print $content ?>) is easy to learn and to read. Printing the results of a function that takes an array as an argument (<?php print render($page['content']) ?>) is more difficult, particularly for new and inexperienced themers who don't know PHP.

Oh, well. Change is inevitable. Except for vending machines ....

Jeff Burnz’s picture

http://api.drupal.org/api/drupal/includes--common.inc/function/render/7

Look at the other functions on that page - drupal_render(), show() and hide(), and then look in Bartiks node.tpl.php file - this is "granular theming".

I agree themeing got more PHP intense in Drupal 7, it was supposed to get easier but in fact got a lot harder.

wdmartin’s picture

^-- Subject says it all.

wdmartin’s picture

I've continued looking, and slowly turned up a bit more useful resources.

If you're new or not very experienced at Drupal theming, try Grok Drupal (7) Theming by Laura Scott at DrupalCon 2010 in San Francisco (hour long video). Among other things, it covers basic changes between Drupal 6 and 7 such as the introduction of html.tpl.php and region.tpl.php. Much of the content will be familiar to people who already know Drupal 6, but it's still a useful starting point.

More advanced themers should consult Design and Theming: What's new in Drupal 7? from the same conference.

In both cases, these presentations were given in April when D7 was in alpha 3. There are very likely to have been changes to the theme system since then, probably many minor ones and a few big ones.

The other thing I've found is that the book Pro Drupal Development has already come out with a new edition for Drupal 7. The first edition (covering Drupal 5) and the second edition (Drupal 6) were both excellent, so I'm inclined to think that the third edition will be very helpful as well. I've ordered a copy but it hasn't arrived yet, or I'd give a review. I'm going to shelve my own D7 theming efforts until this arrives in a week or so.

bloke_zero’s picture

2 drupal con links password protected?

Aeonius’s picture

Is there a kind of "step by step" way of converting D6 themes?
I'd like to update my current theme, but I'm no php programmer.

Jeff Burnz’s picture

Not that I know of, you could google around, but seriously its so many steps, so complicated, that I don't think anyone will ever write the be-all-and-end-all of D6 to D7 theme conversions. In time I imagine generic guides will spring up, or more specific guides for certain themes, but to write a step-by-step that a non-programmer could actually understand and use is a very big ask. Sorry.

Aeonius’s picture

I kinda figured that. Have read through the official documentation several times now. I think I'll just have a go and see where it takes me. Thanks anyway!