1

I am using the contextual filter "Content: Nid" in Views3, and I want it returns the TNID instead of the NID When the filter value is NOT available.

I tried the following code.

$node = node_load($argument);
$argument = $node->tnid;
return $argument; 

I also tried the following code.

$node = node_load(arg(1));
$argument = $node->tnid; // bzw. $argument(1) = $node->tnid;
return $argument; 

I used that code in Provide default value:PHP Code Field, but nothing worked.


I solved the problem by adding this code to the page.tpl.php.

$imagemenuview = views_get_view('projectimagemenu');
echo $imagemenuview->preview('block', array($node->tnid));

I am still interested in the solution using the contextual filter "Content: Nid" returning the TNID instead of the NID When the filter value is NOT available.

1
  • There is an argument “Content translation: Translation set node ID” when core Content translation module is enabled. Is it what you need?
    – kalabro
    Aug 13, 2012 at 12:04

1 Answer 1

0

This PHP code should work:

$node = node_load(arg(1));
return (isset($node->tnid) ? $node->tnid : $node->nid); 

The better way (without evil eval()) is to provide own plugun of type 'argument default' which will do work. Look at Content ID from URL argument default plugin as an example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.