When I try to set up file path, entity reference tokens like [node:og-group-ref] don't work, nothing is returned. I tried to enable and disable all file path options, but that makes no difference. Other tokens, like [node:nid] are working fine. But the token itself is working fine, as I tested it with:

$node = node_load(2998); // Replace 1 with the Node ID you wish to use.
$token = "[node:og-group-ref]"; // Use desire tokens here.
dpm(token_replace($token, array('node' => $node)));

which works fine and returns title of referenced node. Am I doing something wrong? Please let me know, if you need more info.

I'm using latest versions of Filefield Paths and Entity API modules.

Comments

milos.kroulik created an issue. See original summary.

lias’s picture

I am having the same issue.

Using pathauto and setting pattern for the [node:og-group-ref] token it is replaced by the node's og group - which .

When using the same token for filefield path the group isn't inserted into the path, it's ignored.

arx-e’s picture

I met the same problem here too with og-group-ref.
I have not tested another type node reference (beyond OG) yet.

After reading the OG issue 2264759, I tried the last dev version 7.x-2.7+43-dev of OG too but neither this is working.

arx-e’s picture

I just tested with another Entity reference field (non OG) and File (Field) Paths works as expected.

So it seems the problem is actually an Organic Groups issue with tokens (possibly related to the OG issue 2264759).

arx-e’s picture

Title: Entity reference based tokens don't work » Organic Groups Entity reference based tokens don't work
Component: Documentation » Code
Category: Support request » Bug report

I am changing the title to reflect the issue and the category to a bug report.
Still it seems it is not a File (field) Paths bug but an Organic Groups bug.

Deciphered’s picture

Status: Active » Fixed

So the issue is most definitely with OG; At some point before File (Field) Paths gets to do it's thing, OG is removing the value of the field. I have seen this behaviour before and I think I rolled a patch for it.

As a workaround, simply use the following token instead: [node:original:og-group-ref].

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jerrac’s picture

I just tried
groups/[node:original:og-group-ref]/post/[node:title]

[node:original:og-group-ref] was ignored. The file was put in groups/posts/...

@Decicphered, did the patch you rolled get merged into OG? Should I try switching to the dev version of OG?

seanenroute’s picture

I have been having success with [site:og-context--node:nid]. But it's a bit wonky if you try to upload more than 1 files at a time. Not a complete solution but if you are only uploading one file fields it'll get you through the day.

Olafski’s picture

@jerrac - Maybe a bit late, but I wanted to share that the workaround token [node:original:og-group-ref] works for me (after clearing caches). It worked however only for new files, not for old ones using the "Retroactive update" option.

(I'm using OG 7.x-2.10 and Filefield Paths 7.x-1.1.)