Contextual value when the filter is not available and PHP code
I found the cause of the problem from this resource and I have to define the $node variable by:

$node = node_load(arg(1));


Then I use the $node as shown in the question above.