As in title. I'm new to Drupal.

Is this possible, if so what's the most efficient way?

If not what is recommended?

Any help would be appreciated please.

Comments

nevets’s picture

template.php is made up of functions so you need to specify which function you want to get the information in since the most efficient way will depend on the context (or do you mean page.tpl.php?).

limbovski’s picture

The function in template.php is basic_preprocess_search_theme_form.

I want to modify the search form to set the search button as an image with a rollover state.

I am using the variable: $path_to_css = $GLOBALS['base_url'] . '/' . drupal_get_path('theme', 'basic') . '/css';

Followed by:

$vars['form']['submit']['#type'] = 'image_button';
$vars['form']['submit']['#src'] = $path_to_css . '/images/buttons/search.jpg';
$vars['form']['submit']['#value'] = $path_to_css;
$vars['form']['submit']['#attributes'] = array(
'onmouseover' => "this.src='" . $path_to_css . "/images/buttons/search-hover.jpg'",
'onmouseout' => "this.src ='" . $path_to_css . "/images/buttons/search.jpg'");

The problem is when the page renders into html the path for the mouseover and mouseout is:
'http://localhost:8888/mysitename/sites/default/themes/basic/css/images/b..."

which works, yet the path in the img src attribute is this?! "/mysitename/http://localhost:8888/mysitename/sites/default/themes/basic/css/images/b..."

So somehow the root of the site is being appended?

I can't help but think that I'm approaching this completely wrong?

Would be great if someone knew how to get a single quote and not ' also.

nevets’s picture

This

$vars['form']['submit']['#src'] = $path_to_css . '/images/buttons/search.jpg';

should probably be

$vars['form']['submit']['#src'] = drupal_get_path('theme', 'basic') . '/css/images/buttons/search.jpg';

as the form API seems to assume #src is relative to the sites root directory.

limbovski’s picture

Thanks got it working.