cambiare link selettore lingua
Ciao a tutti,
vorrei modificare il path a cui fai puntare il link del selettore lingua.
In modules/locale/locale.module ho trovato la funzione che crea i link:
function locale_block($op = 'list', $delta = 0) {
if ($op == 'list') {
$block[0]['info'] = t('Language switcher');
// Not worth caching.
$block[0]['cache'] = BLOCK_NO_CACHE;
return $block;
}
// Only show if we have at least two languages and language dependent
// web addresses, so we can actually link to other language versions.
elseif ($op == 'view' && variable_get('language_count', 1) > 1 && variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE) != LANGUAGE_NEGOTIATION_NONE) {
$path = drupal_is_front_page() ? '<front>' : $_GET['q'];
$languages = language_list('enabled');
$links = array();
foreach ($languages[1] as $language) {
$links[$language->language] = array(
'href' => $path,
'title' => $language->native,
'language' => $language,
'attributes' => array('class' => 'language-link'),
);
}
// Allow modules to provide translations for specific links.
// A translation link may need to point to a different path or use
// a translated link text before going through l(), which will just
// handle the path aliases.
drupal_alter('translation_link', $links, $path);
$block['subject'] = t('Languages');
$block['content'] = theme('links', $links, array());
return $block;
}
}So modifico la variabile $path da
$path = drupal_is_front_page() ? '<front>' : $_GET['q'];
a
$path = '<front>';
funziona, ma non volevo modificare il core drupal.....
visto che c'è una chiamata a drupal_alter('translation_link', $links, $path); posso mettere nel mio template.php la funzione function MIOTEMA_translation_link_alter( $links, $path){} giusto?
ho provato con questa, ma non funziona...
function MIOTEMA_translation_link_alter( &$links, $path){
foreach($links as &$link) {
$link['href'] = '<front>';
}
}cosa sbaglio?
grazie

Risposte
Ciao, prova a creare un
Ciao, prova a creare un modulo che implementa la stessa funzione:
<?phpfunction [nome_modulo]_translation_link_alter( &$links, $path){
foreach($links as &$link) {
$link['href'] = '<front>';
}
}
?>
vedi se così funziona.
Funziona!! grazie infinite!
Funziona!!
grazie infinite! in effetti se metto la funzione in template.php non viene chamata. se la metto in un modulo si.
grazie!
(Nessun soggetto)