Unleashing the Power of Drupal on Your Theme

299046 8414

Unleashing the Power of Drupal on Your Theme

People love changing things around. Wouldn't it be nice if people could easily swap out images on their home page or even change the background of the theme. Granted, I usually advise against the latter scenario as many people think they know what looks good, but don't realize that their camping escapade isn't always enjoyable by all. However, it can be done! What I think is more important is that it can be done intuitively. Without the need to create new content types, throw in some hard-coded script in your theme's template, or heaven forbid creating an entire module... which, I'll admit, have done once. Oops! :) The documentation on Creating advanced theme settings is an invaluable tool in accomplishing this task. I strongly recommend you read this first before proceeding. Going through implementing this step by step would make this blog post pretty lengthy, so I decided to upload the source files to GitHub in a Gist: https://gist.github.com/1389194. However, I can show you some before and after screenshots of the desired results: Before: Before After: After You can see from the source code (https://gist.github.com/1389194) that I am utilizing the template-settings.php file to render the form for these settings. I am also including some CSS and JavaScript in the form alter hook to help tidy up the UI a bit and included an image preview to show what images will be used. At the bottom of your theme-settings.php file you should include the submission callback to actually save the uploaded images. Here are two screenshots of the theme settings page: Before (using default theme images): Before After (using uploaded images): After

Related Posts

Free Drupal Theme: Jackson (NineSixty Sub-theme)

Brent Bice
Read more

Choosing a Drupal Theme That's Right for Your Business

Brent Bice
Read more

You Never Forget Your First...Drupal Theme

Chris Sloan
Read more

10 Free Photoshop Brushes and Patterns to Spice up Your Bland Drupal Theme

Brent Bice
Read more

DrupalCon Austin - We're Unleashing The Beast!

Brent Bice
Read more

Five Tips for Designing your Next Mobile Theme

Kayla Wren
Read more