D6 - cambiare link delle lingue [RISOLTO]

5 contenuti / 0 new
Ultimo contenuto
D6 - cambiare link delle lingue [RISOLTO]

Ciao a tutti,
vorrei cambiare i link dei selettori lingua. Ora se mi trovo in www.miosito.it/it/nodo/1, il selettore lingua inglese (per esempio) punta a www.miosito.it/en/nodo/1 e non sempre va bene, perché per l'italiano voglio mostrare il nodo/1, ma per l'inglese sarà un altro nodo.
Quello che mi basterebbe fare è far puntare il selettore della lingua alla home. Quindi il selettore 'italiano' punta a www.miosito.it/it/ , quello 'inglese' a www.miosito.it/en/ e cosi' via.

Devo fare l'overriding di qualche hook?
idee?

Oviamente se c'é un altro modo per ovviare al problema suddetto benvenga.

grazie.

ho provato a mettere questa funzione in template.php ma non va....

function acquia_prosper_language_switch_links_alter(&$links, $type, $path) {
  foreach($links as &$link) {
      $link['href'] = '<front>';
      $link['attributes'] = array("class" => "language-link");
  }
}

scusate,
non funziona perché è una funzione per D7...

credo di starci girando intorno....
ho trovato la funzione giusta in modules/locale/locale.module

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;
  }
}

ora grazie a drupal_alter('translation_link', $links, $path); posso scrivere in template.php la funzione MIOTEMA_translation_link_alter($links,$path) giusto?
Chi mi aiuta a scrivere questa funzione?
ho scritto questa ma non funziona....

function MIOTEMA_translation_link_alter( $links, $path){
   foreach($links as &$link) {
         $link['href'] = '<front>';
   }
}

ho risolto(grazie blackice) creando un nuovo modulo. con l'unica funzione

function NOME-MODULO_translation_link_alter( &$links, $path){
   foreach($links as &$link) {
         $link['href'] = '<front>';
   }
}

saluti.