Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #2
lias CreditAttribution: lias commentedI 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.
Comment #3
arx-e CreditAttribution: arx-e commentedI 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.
Comment #4
arx-e CreditAttribution: arx-e commentedI 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).
Comment #5
arx-e CreditAttribution: arx-e commentedI 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.
Comment #6
Deciphered CreditAttribution: Deciphered commentedSo 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]
.Comment #8
jerrac CreditAttribution: jerrac commentedI 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?
Comment #9
seanenroute CreditAttribution: seanenroute commentedI 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.Comment #10
Olafski@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.)