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...
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()
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:<?phpfunction 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
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
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
the cache was the problem
/admin/settings/language/i18n
/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
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
Glad to hear I helped.