Hello! I'm relatively new to Drupal and am trying to alter the output from an existing module (Advanced Forum) without hacking the module. The function I'm trying to override is advanced_forum_theme_image(), which is called several times from within the module. Of course I want to do this from my own module without hacking Advanced Forum. I guess my questions are two:

1) Is advanced_forum_theme_image() an implementation of some hook function? How would I know?
2) If so, how do I intercept it? If not, is it even possible to intercept it?

As usual with Drupal, I'm unsure if I'm even asking the right questions. I am a pretty solid PHP programmer, but not knowing what is calling what and when within Drupal always gives me nightmares. :) Many thanks for any help.

Comments

vm’s picture

the function you pasted sbove calls the theme wrapper. = http://api.drupalhelp.net/api/advanced_forum/advanced_forum.module/funct...

what are you trying to accomplish, by altering that function?

theme functions tend to start with the word theme.

function theme_feed_icon($variables) {
  $text = t('Subscribe to @feed-title', array('@feed-title' => $variables['title']));
  if ($image = theme('image', array('path' => 'misc/feed.png', 'width' => 16, 'height' => 16, 'alt' => $text))) {
    return l($image, $variables['url'], array('html' => TRUE, 'attributes' => array('class' => array('feed-icon'), 'title' => $text)));
  }
}

the word theme is the altered to the reflect the name of the theme in use.

function MYTHEME_feed_icon($variables) {
  $text = t('Subscribe to @feed-title', array('@feed-title' => $variables['title']));
  if ($image = theme('image', array('path' => 'misc/feed.png', 'width' => 16, 'height' => 16, 'alt' => $text))) {
    return l($image, $variables['url'], array('html' => TRUE, 'attributes' => array('class' => array('feed-icon'), 'title' => $text)));
  }
}

the new function is placed in template.php and the cache cleared.

pjohn’s picture

I figured it out... sorry I haven't let you all know before now. I was trying to override how the Advanced Forum module was theming images. What I had to do was use the MYMODULE_theme_registry_alter() function and add a reference to my own theming function. Thanks for your help!

function MYMODULE_theme_registry_alter(&$theme_registry) {
	if (!empty($theme_registry['image']['function'])) {
		$theme_registry['image']['function'] = 'MYMODULE_theme_image';
	}
}
SGhosh’s picture

Thanks. That was the solution even I was looking for! :)