This site is archived.

Theme Preprocess Functions: an Introduction

Theming, Design & Usability

Theme Preprocess Functions: an Introduction

Day:  Tuesday, 24. august 2010
Time:  13:30-14:30
45 minutes (+15 minutes Q&A)

Room:

tags

How many times has this happened to you: You're theming a Drupal site, writing your CSS and making a few changes to the tpl files here and there. Everything is going great, then suddenly you realize you need to change one of those things that starts with a "$" inside those funny-looking <?php ?> tags. Panic!

You exclaim...

"Crap! Where does <?php print $content; ?> come from?! How do I change it?!"

or maybe...

"Crap! I need to have an extra CSS class on this body tag that depends on the taxonomy of the node on the page! Is that possible?!"

or perhaps even...

"Crap! This view is perfect, and it even says which posts are unread, but I need to have the background color for unread item to be different! How can I get that working?!"

Sound familiar?

Preprocess functions are the diplomats of Drupal themes. They are the missing link between what happens in the modules, and what gets sent to the template files.

In this session, we'll dispel PHP fears, and get our feet wet with a little code that goes a long way to helping out with improving the flexibility of our theme.

Prerequisites: Some experience with Drupal theming, general understanding of the templating system, good understanding of HTML and CSS, some basic familiarity with PHP.

Resources

Good pitch :) You got 3 of my

15. August 2010 - 0:43

Good pitch :) You got 3 of my "Craps".
How much familiar with PHP should I be? I can spot a variable in PHP code but I'm afraid that's all.

@Vincent Bidaux Some basic

17. August 2010 - 17:50

@Vincent Bidaux

Some basic familiarity should be sufficient. The purpose of this session is mostly to show you the theory and possibilities rather than technical details.

I will post the code from the examples to this node after the session, so you will have some examples to work from.

For extra PHP guidance, I would suggest skimming W3schools' PHP Basic tutorial, but don't get bogged-down in the details -- just read enough to get a high-level understanding of the concepts. http://www.w3schools.com/php/php_syntax.asp

From Carl: Thanks all in

24. August 2010 - 15:45

From Carl:

Thanks all in attendance. Slides and code examples here: http://growingventuresolutions.com/blog/code-and-slides-drupal-theme-pre...

Enjoy the rest of Drupalcon.

Hey, thanks for this great

24. August 2010 - 17:42

Hey, thanks for this great session! It helped me a lot!

Thanks, Peter.

24. August 2010 - 19:32

Thanks, Peter.

Great Session!! THX!!. By the

26. August 2010 - 20:37

Great Session!! THX!!. By the way... where can i find the slides??

@Alejandro Zielinsky Lisa's

27. August 2010 - 11:56

@Alejandro Zielinsky

Lisa's comment above has a link to the slides. Thanks for attending.

Awesome session. Carl was

27. August 2010 - 11:13

Awesome session. Carl was clear, concise and enthusiastic.

Awesome!!!

22. September 2010 - 23:15

Awesome!!!