pre process functions in template.php
DESCRIPTION
TRANSCRIPT
![Page 1: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/1.jpg)
Pre-Process Functions in Template.php
June 22, 2012
![Page 3: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/3.jpg)
Theme Structure
![Page 4: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/4.jpg)
What is it & when does it happen?
Pre-Process
![Page 5: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/5.jpg)
Processingweb request
![Page 6: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/6.jpg)
Processingweb request
Raw Data (from DB)
Return Data (modules)
![Page 7: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/7.jpg)
Processingweb request
Raw Data (from DB)
Return Data (modules)
Formatted Data (themes)
HTML
![Page 8: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/8.jpg)
$content in node.tpl.php & page.tpl.php
![Page 9: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/9.jpg)
Tools
- Devel module- Admin menu module- Firebug firefox plugin
![Page 10: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/10.jpg)
Floated Right
![Page 11: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/11.jpg)
Floated Left
![Page 12: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/12.jpg)
Tools
yourtheme_preprocess_node($variables)
![Page 13: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/13.jpg)
Variables
Drupal 7: $variables
Drupal 6: $vars
![Page 14: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/14.jpg)
How do I use preprocess with Fields?
- Image (file)
- Image Caption (image description)
- Image Alignment (text - radio buttons)
![Page 15: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/15.jpg)
Create a template.php file, turn on the Devel Module, and use the DSM function.
![Page 16: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/16.jpg)
Refresh your node page twice, and you should see the Kufon display of the node.
![Page 17: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/17.jpg)
We're going to need the following values for field_image, field_image_position
![Page 18: Pre process functions in template.php](https://reader034.vdocuments.net/reader034/viewer/2022051819/54c82a144a795923758b4676/html5/thumbnails/18.jpg)
More Resources
http://drupal.org/node/223430
http://api.drupal.org
Pre-Process can be used on Nodes, Pages, Search Results, Views, User Pictures, and a host of other places in Drupal.