Removing language links in node links

adshill - February 4, 2009 - 11:04

I'm pretty sure this is easy as I've done multi-lingual before and never had this problem, anyway... here goes :)

I've got a multi-lingual site in two languages with translations. At the bottom of every multi-lingual node I have a link to the translation of that page. For example, next to "Add a new comment" I have "Francais" that links to the French version of the page.

How can I get rid of these links? I have a language switcher block so there is really no need for them.

Thanks,

Adam

Still not there...

adshill - February 4, 2009 - 17:15

Ok so I managed to do it through CSS...

.translation-link {
display: none;
}

but this is far from ideal as it just leaves a big gap at the bottom of nodes where it would be.

Any help would be greatly appreciated!

Remove node links using phptemplate_preprocess_node()

dboulet - March 4, 2009 - 14:58

I was able to remove these links using the phptemplate_preprocess_node() function. Here's the code to add to your theme's template.php file:

<?php
function phptemplate_preprocess_node(&$vars) {
 
$node = $vars['node'];
 
// Remove translation links
 
foreach ($node->links as $key => $value) {
    if (
$value['attributes']['class'] == 'translation-link') {
      unset(
$node->links[$key]);
    }
  }
 
$vars['links'] = theme('links', $node->links, array('class' => 'links inline'));
}
?>

There should probably be a better way to do this; it would be great to be able to configure this within the i18n module itself, but this technique works for now.

not working

boriznl - March 4, 2009 - 21:18

Your preprocess function should work, i think but it ist on my site.

I changed the function name, what am i doing wrong?
i have version 6.9 of drupal

What did you rename the

dboulet - March 4, 2009 - 21:41

What did you rename the function to? If you're using a phptemplate theme, try inserting the code exactly as I've provided it. If you already have the line function phptemplate_preprocess_node(&$vars) { in your template.php file, simply insert the following code on a new line following it:

$node = $vars['node'];
// Remove translation links
foreach ($node->links as $key => $value) {
  if ($value['attributes']['class'] == 'translation-link') {
    unset($node->links[$key]);
  }
}
$vars['links'] = theme('links', $node->links, array('class' => 'links inline'));

Once you've inserted the code, try clearing your cache so that Drupal finds the new function.

thx

boriznl - March 5, 2009 - 10:42

the cache was the problem

/admin/settings/language/i18n

frames - March 4, 2009 - 22:11

/admin/settings/language/i18n

I've got an option there called "Hide content translation links", which is what you want, isn't it?

I believe this is coming from i18n itself, althought I also have Language Icons and Consistent Language Interface. Both recommended.

Hide content translation links

dboulet - March 5, 2009 - 00:28

Thank you frames, I have that option on my site as well. This means that I can remove the code that I had previously provided from the phptemplate_preprocess_node() function.

Cool

frames - March 5, 2009 - 00:43

Glad to hear I helped.

 
 

Drupal is a registered trademark of Dries Buytaert.