Hello guys,
i wonder if you can point me to the good direction for my simple issue...

i installed entity reference to refer a node to it's parent.
The site is like a "bid/barter" site every thing is fine for users to register and post an ad but

in an item page / node
i want any register user to submit an item to barter (Content type: offers_to_others)
i have a field which is an entity reference which must be set to a view to filter results to the current page i guess..
i created a contextual filter for the CONTENT:NID
where i provide a php default value:

//PHP contextual filter code
if (arg(0) == 'node' && is_numeric(arg(1))) {
  // Get the nid
  $nid = arg(1);
  // Load the node if you need to
  $node = node_load($nid);
}

if i print/dump it alone i get:

arg[0] = node;
arg[1] = 6;

but my select input in the rendered form has every node

Can anyone tell me where i am wrong?
Thanks
Luke.

EDIT

After few tests if i choose the default value as : CONTENT ID FROM URL, It works.

Shouldn't it works from my former PHP code also?

Comments

nevets’s picture

Sounds like you are looking for the Entity Reference Pre-populate module.