Ho una funzione di theme che vorrei overridare. Posto il code originale, del modulo image:
<?php
/**
* Implementation of hook_theme() registry.
**/
function image_gallery_theme() {
return array(
'image_gallery' => array(
'arguments' => array('galleries' => NULL, 'images' => NULL),
),
'image_gallery_count' => array(
'arguments' => array('count' => 0),
),
'image_gallery_updated' => array(
'arguments' => array('timestamp' => 0),
),
'image_gallery_img' => array(
'arguments' => array('image' => NULL, 'size' => NULL),
),
);
}
/**
* Theme a gallery image.
*/
function theme_image_gallery_img($image, $size) {
$width = $size['width'];
// We'll add height to keep thumbnails lined up.
$height = $size['height'] + 75;
$content = '<li';
if ($image->sticky) {
$content .= ' class="sticky"';
}
$content .= " style='height : {$height}px; width : {$width}px;'>\n";
$content .= l(image_display($image, IMAGE_THUMBNAIL), 'node/'. $image->nid, array('html' => TRUE));
$content .= '<h3>'. l($image->title, 'node/'. $image->nid) .'</h3>';
if (variable_get('image_gallery_node_info', 0)) {
$content .= '<div class="author">'. t('Posted by: !name', array('!name' => theme('username', $image))) ."</div>\n";
if ($image->created > 0) {
$content .= '<div class="date">'. format_date($image->created) ."</div>\n";
}
}
$content .= "</li>\n";
return $content;
}
?>
Vorrei poter overridare in un mio modulo la theme_image_gallery_img, facendo si che, richiamando questa funzione, si chiami il mio callback e non quello definito da image.
Come si può fare?
Grazie
Non nel modulo, ma nella tua tema. Più specificamente
template.php
Per ogni
theme_vatelapesca(params)
poi scrivere una funzionefunction nome-della-tema_vatelapesca(params) {}
e questo verrà chiamata invece ditheme_vatelapesca()
Dopo ogni funzione aggiunta, non dimenticare di pulire la cache del registry tema...
Più imparo, più dubito.
mmm questa cache come si pulisce?
drupal_rebuild_theme_registry();
Si, o tramite il comando di admin_menu, o caricando la pagina degli teme.
Più imparo, più dubito.
infatti ^^