I ran into the problem where if I tried to link to use the ' as link' formatter in a view it was linking to the wrong page (the initial page, not the translated page).

I solved this problem with the following code in my template.php file. I am only using English and French on my site...

Note the comments to see the differences from the normal theme_imagecache_formatter function.

function phptemplate_imagecache_formatter($field, $item, $formatter) {
	global $locale; // Added by swill so it could be referenced.
  if (preg_match('/_linked$/', $formatter)) {
    $formatter = preg_replace('/_linked$/', '', $formatter);
    $image = theme('imagecache', $formatter, $item['filepath'], $item['alt'], $item['title']);
		// START - Updated by swill to get translations working for french...
		if ($locale == 'fr') {
			$translated_nid = translation_node_nid($item['nid'], 'fr', $item['nid']);
			$output = l($image, 'node/'. $translated_nid, array(), NULL, NULL, FALSE, TRUE);
		} else {
			$output = l($image, 'node/'. $item['nid'], array(), NULL, NULL, FALSE, TRUE);
		}
		// END - Updated by swill to get translations working for french...
  }
  else {
    $output = theme('imagecache', $formatter, $item['filepath'], $item['alt'], $item['title']);
  }
  return $output;
}

Comments

drewish’s picture

Status: Active » Closed (won't fix)

5.x-1.x is unsupported. if it's a problem in later releases re-open the issue.