Give us a call 888-856-2664
Get a Quote Today

Things a Chameleon Would Say

Web design

Theming image buttons in Drupal
By: Max Rakhimov 10/04/2010

Here is a simple code snippet for those who want to make some of the submit buttons on their Drupal website image buttons:

function MYTHEME_button($element) {    if ($element['#value'] == t('Search')) {     $element['#src'] = drupal_get_path('theme', 'MYTHEME') . '/images/search_button.png';     $element['#button_type'] = 'image_button';   }   if ($element['#button_type'] == 'image_button') {      return theme_image_button($element);   }   else {     return theme_button($element);   } }

The above code goes into your template.php file in your theme folder. Make sure to rename MYTHEME with your theme name. You can look up $element['#value'] from the page code, it is the ‘value’ of the button element. The code snippet is for Drupal 6.

Leave a Reply




Have a Question? Need a Quote?

Drop us a line or give us a call at 888-856-2664

Your Name (required)
Your Email (required)
Phone (required)
Your Message

What Our Clients Are Saying

John,
Can I just tell you how impressed I am with your team?! This whole process has been so great and working with you guys has made it SOOOO much easier! Thank you for all your hard work and for convincing us to choose Accella.

SO THRILLED!!

Alycia White
Kubota

Recent Posts

Getting Arrested Can Help Your Business

While generally coming face to face with the law is generally not good for...

Drupal 6 with UberCart / UberPOS - A Love-Hate Relationship?

As most techies and programmers have heard, the Drupal CMS is an extremely...