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.
The following Pathauto tokens no longer exist.
[ogname] - Title of top group
[ogname-raw] - Unfiltered title of top group. WARNING - raw user input.
[og-id] - ID of top group
[og-type] - Type of top group
[ogalias] - URL alias for the top group.
Screenshot: http://awesomescreenshot.com/00090aof4
What can I use to substitute for these missing tokens?
Comment | File | Size | Author |
---|---|---|---|
#78 | Screen shot 2011-06-11 at 10.40.40 AM.png | 28.72 KB | cartagena |
#78 | Screen shot 2011-06-11 at 10.40.20 AM.png | 16.27 KB | cartagena |
#75 | og_token.tar_.gz | 794 bytes | jupeter |
#44 | og_tokens-met-a.patch | 7.76 KB | quimrovira |
#23 | og-tokens-met.patch | 10.1 KB | quimrovira |
Comments
Comment #1
bryancasler CreditAttribution: bryancasler commentedComment #2
bryancasler CreditAttribution: bryancasler commentedI think I preemptively closed this.
I'm following this issue que, but it doesn't look to have resolved this.
#691078: Field tokens
Comment #3
tbenice CreditAttribution: tbenice commentedsub
Comment #4
bfroehle CreditAttribution: bfroehle commentedOrganic groups historically has provided organic group's tokens.
Comment #5
amitaibuCheck out the -dev, I've just added yesterday tokens support.
Comment #6
bryancasler CreditAttribution: bryancasler commentedThis one?
7.x-1.x-dev tar.gz (141.74 KB) | zip (176.75 KB) 2011-Mar-08 Notes
http://ftp.drupal.org/files/projects/og-7.x-1.x-dev.zip
Comment #7
bryancasler CreditAttribution: bryancasler commentedThanks for your work Amitaibu. I just installed the dev and I got a few new options to show up :) I'm still looking for "group_audience" or a facsimile of it. I'll keep tabs on this issue que, I really appreciate your hard work.
Comment #8
jastraat CreditAttribution: jastraat commentedI'm using -dev from March 14th, and I'm afraid I don't see organic group tokens even after applying the tokens module patch from http://drupal.org/node/691078#comment-4139738
Now I see other field api tokens, but nothing from organic groups.
Comment #9
jastraat CreditAttribution: jastraat commentedComment #10
amitaibu@ jastraat,
DO you have Rules installed? You can see the og tokens being used with the default Rules that come with og -dev.
Comment #11
jastraat CreditAttribution: jastraat commentedI do not have rules installed. I'm trying to use og tokens with pathauto.
Comment #12
amitaibu> I'm trying to use og tokens with pathauto.
You will not see the og tokens, as they don't have a group context.
Comment #13
jastraat CreditAttribution: jastraat commentedThis confuses me I'm afraid; if I add a group audience field to a content type, the value I store in a node won't be available for pathauto to use..?
Comment #14
quimrovira CreditAttribution: quimrovira commentedHi!
The following patch tries to enhance OG tokens a bit, introducing the following changes:
Beware:
This would have to be renamed to "admin", i suppose, since it fetched the user object via it's entity (node) author
I use this patch mainly together with menu_tokens module to provide some wierd menus (if you happen to do the same thing, make sure to use the -dev version, due to #1092820: Current page tokens cannot be verified when savin menu item).
Also, the problem exposed by #7 and #11 is related to accessing arrays of data using tokens, and it's being discussed on this token module issue: #1047740: Add an [array:*] token type and a [user:roles] token.
I think the most reasonable approach by now would be to wait for them to define a nice scheme to access fully typed arrays with tokens, and stick to it. Myself, I created a custom token that just returns the first group listed in the audience, but it's useless if you happen to use multiplicity on audiences.
Comment #15
quimrovira CreditAttribution: quimrovira commentedThis patch has the simple node audience token i was using for pathauto, ported to be applied over the last one in #14.
Just thought I would share this as an example for #7 and #11. My advise would be to create a custom module and register those tokens there using custom names (e.g: my node subtokens are called "qr-ognode", and directly return the group node instead).
Comment #16
gilzero CreditAttribution: gilzero commentedsubscribe.
I am also looking for passing gid to pathauto, is there a way to do so?
Thanks.
Comment #17
amitaibu@quimrovira,
Thanks for working on this.
This should be in og-context module.
Missing dot in end of line.
Please add in the documentation why this is needed.
use a variable called $account instead of $user (as objects are passed by reference, and we don't want to have a security risk that the $user object will change).
Move this to og-context.
Powered by Dreditor.
Comment #18
bryancasler CreditAttribution: bryancasler commented+1 for everyone working on this.
Comment #19
Jackinloadup CreditAttribution: Jackinloadup commentedIs patch #14 rolled into the token branch? http://drupal.org/node/13446/git-instructions/tokens
Comment #20
quimrovira CreditAttribution: quimrovira commentedI've just reviewed the patch i submitted to take into account amitaibu's suggestions:
Also, the second patch i submit (noerrors) makes any undefined tokens not generate any replacement pairs at all.
Rationale: Invalid tokens usually generate no replacements (e.g: unexistant fields, chained access on undefined elements, etc.), and this case is treated nicely by pathauto, which simply deletes any unreplaced tokens. I couldn't find if this behaviour is defined or not by D7 specification, but allows some nice things, like setting "[node:simple-audience:url:alias]/issues/[node:title]" as url for some group content types, which would result on /pathto/mygroup/issues/node-title, yet allowing fallback to /issues/node-title when no group audience was selected.
Btw, the audience token patch was not merged in, yet.
#16 -> Using latest git/dev release of og, and applying the horrible patch on #15 you should be able to use [node:simple-audience:gid] on pathauto. You'll have to apply the patch by hand, and expect inconsistencies and token name changes whenever (if ever) it gets into mainstream og.
Comment #21
amitaibuI'm going to push my luck here -- quimrovira, any chance for some tests with this patch ? :)
Comment #22
quimrovira CreditAttribution: quimrovira commentedI'll be happy to provide some tests as as soon as i have some spare time to write them down :)
Comment #23
quimrovira CreditAttribution: quimrovira commentedNew version of the noerrors patch, that includes mostly everything above except the [node:audience:*] tokens, and also a new set of tests for OG tokens. Also, [group:manager:*] tokens are no longer node-only, since they should work with any entity (i think).
I've placed the token tests on the main og.test file. They all pass on a clean d7 installation with the git 7.x-1.x version, so far.. post any fails here and I'll try to fix them asap!
Comment #24
quimrovira CreditAttribution: quimrovira commentedfix status to trigger testing!
Comment #25
cartagena CreditAttribution: cartagena commentedThank you to everyone working on this...I was using the 7.x-1.0 Jan 5 release and as a non-programmer was finding it challenging to keep up with the patches and discussions and decided to wait for a more stable version. I then uninstalled OG and went about developing other parts of the site. I upgraded to the Mar. 23 dev release this morning and could not get the approve member function to work. The person asking for permission would appear on the group manager's group tab and when clicking update the green message bar would still say it was updated but the status would remain pending. At first I thought it was a conflict with Content Access which I'd installed in the interim so I uninstalled that and still had the problem. After trying every config of permissions and fields I could think and uninstalling and re-installing several times I finally uninstalled it and went back to the Jan 5 release and that works OK.
On one of my installs this is the message I received on the white screen of death when I tried to update a member status: Fatal error: Unsupported operand types in /Users/xxxxxx/xxxxxx/version2/sites/all/modules/og/og.module on line 1468
Again, thanks to all, I am very, very grateful for all your work.
Comment #26
cartagena CreditAttribution: cartagena commentedFor what it's worth, there is a conflict with Control Access...any content I had limited access on, all the fields disappeared when I enabled OG. After several attempts I tried it iwthout enabling the OG field access and I controlled field access with Control Access and got it all back...I'd be grateful for any suggestion about how I should go about this. My site goes live in just over a couple weeks with the launch of a book in Washington and NY that will bring many folks to it wanting to sign up.
Thank you again.
Comment #27
quimrovira CreditAttribution: quimrovira commentedNo offense, cartagena, but you should try to post such information on it's own issue. Take into account that posting on any unrelated issue causes confusion and makes managing the open issues for mantainers more difficult ;)
If you look at the original issue in this page, you'll see that we're all discussing about a very specific organic groups feature: token support.
Reading your two comments, I guess your membership approval problems are related to these issues: #911256: Adding user to a group fails and/or #1103002: group/%/%/admin/people membership 'state' is not set correctly
Comment #28
cartagena CreditAttribution: cartagena commentedThank you, quimrovira. I did find the other issue page. I'm new to this and I'm not always sure what to search for or what the correct terminology is for the problem I'm having. Guidance is welcome. I'll be more careful.
Comment #29
rorymadden CreditAttribution: rorymadden commentedsubscribe
Comment #30
amitaibu@quimrovira,
Great I'll go over it.
Other people, instead of "subscribe" you should test the patch...
Comment #31
RobKoberg CreditAttribution: RobKoberg commentedI want to test. How does one apply these patches? I have recently pulled the latest code from the git repo. I downloaded the patches to my og working directory and tried to apply the patches, but:
~/Sites/field/drupal/sites/all/modules/og$ git pull
Already up-to-date.
~/Sites/field/drupal/sites/all/modules/og$ ls -l *.patch
-rw-r--r--@ 1 rkoberg staff 1174 Mar 27 09:00 og-horrible-first-audience-met.patch
-rw-r--r--@ 1 rkoberg staff 3316 Mar 27 09:01 og-tokens-met-2-no-errors.patch
-rw-r--r--@ 1 rkoberg staff 4343 Mar 27 09:01 og-tokens-met-2_0.patch
~/Sites/field/drupal/sites/all/modules/og$ git apply og-horrible-first-audience-met.patch
error: patch failed: og.tokens.inc:55
error: og.tokens.inc: patch does not apply
Is there someplace I can just grab the already modified files?
Comment #32
amitaibu@RobKoberg,
You need to use only a single patch -- the latest one posted, not all posted patches. Thanks for testing it out.
Comment #33
RobKoberg CreditAttribution: RobKoberg commentedThis seems to work fine as is. Hoping for more :)
In my case, I have created group hierarchies and want to have the URL alias built up from the parent group's URL (the group audience URL). What is the most efficient way to get a $group->group_audience path? My try below works, but could use help and any advice would be appreciated. It allows me to create a URL Alias for the group hierarchy like so:
[group-audience:url]/[node:title]
What I have done so far is add to og_context.tokens.inc (at line 18):
and in og.token.inc at line 72:
Comment #34
quimrovira CreditAttribution: quimrovira commented@RobKoberg: This is essentially what the horrible patch in #15 does. The reason why it has not been considered yet is because it looks like there's no consistent way to treat arrays using tokens, and I'm currently waiting for feedback on a similar issue on the token module: #1047740: Add an [array:*] token type and a [user:roles] token, where they provide a few useful tokens, but only for scalar/string types, and we've got an array of groups here.
Anyway, as I said, I'm currently using the same approach as you, while we wait for that. ;)
Comment #35
amitaibuThere are in the dev some Rules configuration that are using tokens. I think this patch will break, since the tokens are renamed, no?
Comment #36
quimrovira CreditAttribution: quimrovira commentedOk, I'll try to check that ;)
Comment #37
amitaibu@quimrovira,
Can you re roll patch using --no-prefix, so I can apply the patch and test it?
Comment #38
amitaibuToo many spaces, shoudl be
(array('name' => 'group'));
Assert message should end with a dot (.)
Lets have the assertion in one line. You can have $value1, $value2 as variables to do the assertion, so the line won't be too long.
We are testing also the users here, so the name isn't so good. Maybe testOgEntityTokens?
This test seems to be in previous test already. Aslo we should test for a token of a group:node:title , that is not a node.
Maybe better "Group manager user".
Why do you change this -- we might pass a group that still wasn't save.
No need to if the $group->getEntity(), there is no reason to not get it. Removing it will make it a little more readable.
Powered by Dreditor.
Comment #39
bfroehle CreditAttribution: bfroehle commented@Amitaibu:
--no-prefix
is on its way out. You can read about how to apply patches created without that at http://drupal.org/patch/applyComment #40
amitaibuI have created a tokens branch -- http://drupalcode.org/project/og.git/shortlog/refs/heads/tokens
This is the last task on my todo before a release.
Comment #41
quimrovira CreditAttribution: quimrovira commentedOk, I'll review this today to avoid keeping back the next release.
About your comments on the above snippets:
Comment #42
amitaibu@quimrovira,
You can pull from the tokens branch, and create your own branch in the sandbox, like this we can pull from each other.
Comment #43
Anonymous (not verified) CreditAttribution: Anonymous commentedWhen trying to update the member status in a group I receive the same error message as #25. Is this an issue that has something to do with tokens? If not should I open up another issue for this? Here is the call stack:
# Time Memory Function Location
1 0.0016 331488 {main}( ) ../index.php:0
2 1.0813 31917652 menu_execute_active_handler( ) ../index.php:22
3 1.0847 32143356 call_user_func_array ( ) ../menu.inc:501
4 1.0847 32143624 drupal_get_form( ) ../menu.inc:0
5 1.0847 32144264 drupal_build_form( ) ../form.inc:188
6 2.5957 45684504 drupal_process_form( ) ../form.inc:350
7 2.6000 45724740 form_execute_handlers( ) ../form.inc:830
8 2.6000 45726720 og_ui_user_admin_account_submit( ) ../form.inc:1390
9 2.6009 45730328 call_user_func_array ( ) ../og_ui.admin.inc:279
10 2.6009 45730344 og_ui_user_operations_block( ) ../og_ui.admin.inc:0
11 2.6009 45730372 _group_ui_user_operations_set_state( ) ../og_ui.module:555
12 2.6010 45730796 og_group( ) ../og_ui.module:573
Comment #44
quimrovira CreditAttribution: quimrovira commentedApplied the suggested changes on a sandbox at http://drupal.org/node/1122604 (I've given amitai full access just in case)
Patch also attached, but it was generated against the token branch, not 7..x-1.x!
Comment #45
amitaibuI have pushed some code cleanup in my branch. I have noticed you have
which is never used.
Comment #46
quimrovira CreditAttribution: quimrovira commentedYes, it was left behind because of the node:audience tokens which are not yet on the git repo..
if you think a token for the first audience field value should get into the release, i can commit my node:simple-audience token too (could take a while to get the base typed array support into token module, and i haven't had much time to look into that)
Comment #47
amitaibu> if you think a token for the first audience field value should get into the release
Better than nothing I guess ;)
Comment #48
bryancasler CreditAttribution: bryancasler commented+1 for "token for the first audience field value"
Comment #49
amitaibu> where missing or unreplaced tokens is nicely handledd by the calling module
> What do you think would be better here?
I'd like to imitate user.module -- which returns "not yet assigned" (as currently the code in tokens branch does).
Comment #50
amitaibuWe also need to add token for og-membership entity (and move [created] from group to og-memnbership). After that we can fix the Rules integration.
Comment #51
amitaibuOh MY! I have completely missed the fact that entity API already provides token integration :/ So most of the work was already by implementing the metadata class...
Comment #52
amitaibu#1123920: Dependent metadata
Comment #53
Aeternum CreditAttribution: Aeternum commentedSubscribing...
Comment #54
Parke CreditAttribution: Parke commentedI've been trying my hardest to apply these series of patches and custom dev work-arounds to support og assignments on nodes to display in pathauto's URL aliases.
I can't seem to get the first audience value to populate using steps listed in this issue. Mainly quimrovira's #20 post regarding #16. [node:simple-audience:gid] returns a generic invalid token error.
If you have another option as a work-around, please let us know; if one of the suggestions above is the best option, I'll get back to the drawing board. :)
Thanks for all your work.
Comment #55
amitaibuThe token is now implemented in the -dev version -- you need to enable entity-token module.
Note that indeed until #1047740: Add an [array:*] token type and a [user:roles] token there is no support for tokens that are a list (so you can't do for example [node:og_membership(1):group:label]; however on a group node you can [node:group:label].
I'll keep on needs work until I update docs.
@quimrovira,
One big sorry for letting you do the hard work and in the end taking another approach, but I think it's for the best. Do stay in OG's issue queue ;)
Comment #56
bryancasler CreditAttribution: bryancasler commentedAmitaibu I just tried the most recent dev build, but I'm not seeing any additional tokens. I ran update.php, but it said nothing needed to be updated. I'm using Entity API and Entity tokens 7.x-1.0-beta8
http://awesomescreenshot.com/033bs4gd9
Am I missing something?
Comment #57
amitaibu> Am I missing something?
You missed my comment:
> Note that indeed until #1047740: Add an [array:*] token type and a [user:roles] token there is no support for tokens that are a list (so you can't do for example [node:og_membership(1):group:label]; however on a group node you can [node:group:label].
Comment #58
bryancasler CreditAttribution: bryancasler commentedThanks Amitaibu
Comment #59
quimrovira CreditAttribution: quimrovira commentedI'm still here, but i was away mostly due to easters.. I'll try to get back to this issue the next few days and sort it out!
Comment #60
Dave ReidTracking as token maintainer.
Comment #61
sitekick CreditAttribution: sitekick commentedComment #62
sitekick CreditAttribution: sitekick commentedSubscribing...
Comment #63
bryancasler CreditAttribution: bryancasler commentedAmitaibu, I just upgraded to the new Beta 2 Token release and I noticed some possibly new options.
http://awesomescreenshot.com/09edg9551
http://awesomescreenshot.com/024dg9add
Does this resolve the current hurdle of #1047740: Add an [array:*] token type and a [user:roles] token?
EDIT: I just remembered I am using this token patch from #143 as suggested by #262. #691078: Field tokens
Comment #64
_petja CreditAttribution: _petja commentedI'm using the latest dev of og and can't use [node:group:label] in my url patterns. I have entity token beta8 in use. I'm probably missing something but just can't see what that is.
Comment #65
_petja CreditAttribution: _petja commentedallthough i just found this [site:current-group:label] which seems to be giving current groups name...
Comment #66
amitaibuI've Added docs about views/ rules/ tokens integration and FAQ section, so marking fixed.
Comment #67
bryancasler CreditAttribution: bryancasler commentedHere is a link to those FAQ updates.
http://drupalcode.org/project/og.git/blobdiff/e3c8cbb6ca42ce0b5c06e59a6c...
Comment #68
jastraat CreditAttribution: jastraat commentedI'm afraid I'm still having difficulty with organic groups + pathauto. I am using the following modules:
Entity API (with Entity tokens enabled) 7.x-1.0-beta8
Token 7.x-1.0-beta2 + the field tokens patch: http://drupal.org/node/691078#comment-4139738
OG 7.x-1.1-rc3
I'm not seeing any tokens related to organic groups except:
[node:group-group] and [node:group-theme]
None of the following work:
[node:group:label]
[site:current-group:label]
[node:group-audience]
Please - what am I missing? Thank you in advance!
Comment #69
jupeter CreditAttribution: jupeter commentedI have same problem as jastraat have (with same modules versions).
I seeing [node:group-group] and [node:group-theme], but none others.
I'm trying with og-7.x-1.1-rc3 too, but without luck ...
Any ideas?
Comment #70
amitaibu> None of the following work:
You mean you don't see them on the list, or when you add them it doesn't get the token?
Comment #71
bryancasler CreditAttribution: bryancasler commentedI'm using the following without any patches applied
Drupal 7.x-2.0
OG 7.x-1.1-rc3
Entity API 7.x-1.0-beta8
Token 7.x-1.0-beta2
When looking at pathauto I only see "[node:group-group]", I do not see [node:group-theme]
http://awesomescreenshot.com/0a5dw8456
If I try to use "[node:group-audience]" or "[node:group:label]" with pathauto, I am unable to and I get the following warning.
http://awesomescreenshot.com/041dw864a
SOLUTION: To get the current group the node is posted to, you can use [site:current-group:label]
http://awesomescreenshot.com/061dw8tc7
Comment #72
jastraat CreditAttribution: jastraat commented@Amitaibu Both - the tokens do not appear in the list and they do not work when entered.
@animelion - [site:current-group:label] did not work when I tried it. Pathauto accepted it as a token, but it did not generate anything for the path when creating a new group content node (which is what I applied the token to.)
Comment #73
jastraat CreditAttribution: jastraat commentedBased on the screenshot above, I tried [site:current-group:url]. This did work but it takes the FULL url path - including the site base url. It seems like the token should only include the 'path' portion of the group's url -
It's worth mentioning that unless using a query string appended to the node add url, pathauto won't have a 'current-group'.
Comment #74
jastraat CreditAttribution: jastraat commentedInterestingly, [site:current-group:label] does display as a possible token when configuring file paths for image fields. It works for the most part, with one strange problem.
If you create a multi-value image field, the first image uploaded goes to the correctly named directory. The SECOND file (and all subsequent ones) go into a directory called '[site:current-group:label]'; the token is apparently not parsed. If the user uploads one file, then saves, then uploads another, the token works as expected. To try to establish if this was a core problem with tokens, I tried using the [current-user:name] token. That token worked as expected with multiple files all going into the correct directory, so I believe this is a problem specifically with OG's tokens or possibly with the Entity API.
Comment #75
jupeter CreditAttribution: jupeter commentedFor my need's, i've created new module for OG tokens (see attachment).
After install we have new token: [group:uri] (work for new and exists nodes).
Comment #76
jastraat CreditAttribution: jastraat commented@jupeter -
This is a cool idea. However - it looks like you're using $gid for $nid when those aren't the same thing.
gid is the Group ID, not the Node ID. You'd need to do something like:
$node = og_load_entity_from_group($gid);
to get $node->nid
Comment #77
jastraat CreditAttribution: jastraat commentedJust tried this module out with the following changes:
And it appears to work like a charm with pathauto. And it doesn't require the query string for the group to be passed through the URL for creating new content which is really nice.
Any chance of this getting into the OG module?
Comment #78
cartagena CreditAttribution: cartagena commentedThanks for the module and the fix...but I must be doing something wrong. I am using latest dev version of og, views, modules, token etc. I now get the new og tokens when I go to set url patterns. But the only one that works is group:uri. I've attached screen shots of what I'm looking at. Any suggestions would be most appreciated. I've cleared cache numerous times. And still can't get any other patterns. Thanks!
Comment #79
amitaibuI have added a fix to get [node:group:label] working again.
Comment #80
cartagena CreditAttribution: cartagena commentedThank you! I've got my groups set up on my test server, hope to make them live very soon. I am simply AMAZED at what I can do with OG, panels, views and rules as far as having private and public groups and content. Add a little css and some theming and it's great! Still trying to understand contexts and relationships for some additional things I want to do, but even so, what all you developers have done is incredible. Thanks again, it's incredible!
Comment #81
cartagena CreditAttribution: cartagena commentedThank you! I've got my groups set up on my test server, hope to make them live very soon. I am simply AMAZED at what I can do with OG, panels, views and rules as far as having private and public groups and content. Add a little css and some theming and it's great! Still trying to understand contexts and relationships for some additional things I want to do, but even so, what all you developers have done is incredible. Thanks again, it's just awesome!
Comment #82
Pavlos-1 CreditAttribution: Pavlos-1 commented#71 worked for me!
Thank you
Comment #83
Aeternum CreditAttribution: Aeternum commentedHi there,
I'm running the dev version from today, and the new tokens appear in the list, but they don't actually work (that is, they come out blank).
Any suggestions?
Comment #84
jastraat CreditAttribution: jastraat commentedFrom my comment in #73 -
Unless you are using a query string appended to the node add url, pathauto won't have a group context to populate the tokens.
Comment #85
KarenS CreditAttribution: KarenS commentedI'm using the latest dev versions of everything, OG, Entity, Entity Tokens, Pathauto, and I see all of the group tokens as options but none of them work. I have tried both the node:group and the site:current-group tokens (and numerous variations of them, like site:current-group:labels) and absolutely none of them do anything in pathauto patterns. When I delete and recreate my aliases, all of them end up empty.
Comment #86
amitaibuI'll have to recheck.
Another option you guys and gals should check is using Rules to set the path. I think Rules can better manipulate the tokens than pathauto.
Comment #87
awasson CreditAttribution: awasson commentedI'm using the latest non dev releases on a D7 proof of concept: Organic groups 7.x-1.1, Pathauto 7.x-1.0-rc2, Entity API 7.x-1.0-beta10, Token 7.x-1.0-beta5, etc...
I have been able to use [node:group_audience] in my Group Content's URL Patterns but I must not hide the Group Audience field for my content type. I don't typically want to see the Group Audience field in the content area so I'm using CSS to hide it but it does work as a replacement pattern. I haven't been able to get any of the others to work though ([node:group-group], [node:group], etc...).
My goal is to include the taxonomy term of the Group ([node:group_audience]) that this content falls under but I haven't had any success yet. The replacement will hopefully then be something similar to:
Comment #88
Dave ReidIf the tokens are appearing blank then it would mean that the data is not provided properly in token replacement. Not sure how Rules would fix that.
Comment #89
awasson CreditAttribution: awasson commented@Dave Reid: That's the conclusion that I came to in my tinkering with Token/Entity Tokens while trying to create some patterns in Pathauto. I think everything that has data is actually showing up.
On a sideline and this being the case, if I need to extend my tokens so that I can grab a reference to the Taxonomy term of an OG Audience or the Taxonomy term of the Organic Group a piece of content belongs to, what's the direction I should be looking in? I am truly baffled.
Thanks,
Andrew
Comment #90
Argus CreditAttribution: Argus commentedCurrently the only way I can get this working is to set BOTH Pathauto and Rules to [site:current-group:label]/[node:title]. Strangely either of them alone doesn't work.
Comment #91
pfrenssenI needed a token today that outputs the labels of the groups a node belongs to. I could not get it to work using [node:group_audience].
I really needed this functionality so I created a small module that provides a new token [node:og-group-audience]. This outputs group labels as a comma separated list, or allows to retrieve a single group label by using the array functions of the Token module.
My use case was to generate custom URL aliases that contain the group name using Pathauto. I needed a filename pattern like 'group/[node:og-group-audience:first]/event/[node:nid]'.
Comment #92
amitaibu@Dave Reid
All the tokens in OG are actually defined via entity-metadata and "exposed" via entity-tokens module. Some properties can't be used as token -- #1058856: Entity tokens not created for multi-value fields. However Rules itself, can you those metadata properties (even lists), so one doesn't actually use tokens but the metadata system itself.
Comment #93
muschpusch CreditAttribution: muschpusch commented@Amitaibu
Most of the og tokens aren't available to rules. You can access them in the data selection of rules but they don't have values (check gid). Really ugly workaround: create an extra field and save the data on hook_form_alter until this is fixed!
Comment #94
amitaibu> You can access them in the data selection of rules but they don't have values (check gid)
You are right, I though the data selectors are available also on "direct input" mode.
Comment #95
muschpusch CreditAttribution: muschpusch commented@Amitaibu: I think you got me wrong it doesn't matter if you use 'data selector' or 'direct input' mode. The value of e.g. 'gid' is always empty.
Comment #96
amitaibu@muschpusch,
The thing is that OG doesn't have even a single line of code that deals with tokens. Entity-tokens module just takes the metadata info from OG, so I suspect it should be handled upstream -- as Entity API's issue.
Comment #97
muschpusch CreditAttribution: muschpusch commentedDo you have a clue what it could be? I could open an issue in the entity api issue queue or do you want to do it? Rules integration is kind of crucial for me... As far as i get it: if you implement hook_entity_property_info() properly rules and all the stuff is for free :) You did that so i have no idea what could be wrong... I will have a better look at hook_entity_property_info() later!
Comment #98
muschpusch CreditAttribution: muschpusch commented@Amitaibu: Sorry for spamming, but couldn't it be related to the bugs related to arguments and relationships in views? I found this issue: #1041066: Passing OG arguments in Views
Please correct me: Arguments in views only work when overwritting the nid (argument) with the group id? Since the tokens are exposed to UI but there are empty couldn't be the same think happening here?
Comment #99
muschpusch CreditAttribution: muschpusch commentedI don't think that's it's related to #98 but it could be related to: #1058856: Entity tokens not created for multi-value fields
I opened a new issue in the entity api queue:
#1320916: token support for organic groups
Comment #100
fagoI just ran into that issue too. Well, the problem is that the og relations are so generic, e.g. this gets me the group node of a content node:
-> [node:og-membership:0:group:entity]
Of course, there are no generic-entity tokens though... Also, this results in bad SBX (site builder exp :D) in Rules. Although it's rather complicated in Views too :(
I'd prefer being able to just use it that way:
[node:membership:0:node]
E.g. by using separate membership properties by membership type? Then we can associate group-fields with membership types + restrict the group-entity type by membership type. That should be fine as usually I don't want to have different entities for the same kind of group.
-> That would already easy the case for getting from group content to the group entity. E.g. it could be
[node:group-membership:0:entity] which is declared to be a node - that way tokens like [node:group-membership:0:group:entity:title] would work out-of the box.
Then, I wonder whether there is still a use-case for having the group-entity as we have group memberships now? Removing that would also make it much simpler, including Views. But that's probably out-of-scope to change it now :(
Comment #101
fagoIdea:
Additionally, we could restrict possible group membership types in the group-audience field settings. That way, we could generate *useful* membership properties per-field.
Comment #102
amitaibu> I'd prefer being able to just use it that way:
[node:membership:0:node]
The problem is that og_membership points to the group ID, and changing it to point to the entity_type and entity_id can make stuff more complicated (things like entityFieldquery).
> Then, I wonder whether there is still a use-case for having the group-entity as we have group memberships now?
Funny, just yesterday I was thinking if we really need the group entity. I think we still do as we need a group ID, and we need to be able to get the group's label for autocomplete widgets.
Anyway I don't think the group membership can replace the group, as it defines the connection between a group content to a group.
> Additionally, we could restrict possible group membership types in the group-audience field settings
It's actually happening in #1263588: Allow having multiple group-audience type fields (you should check that branch out :D), where you define a membership type per group audience field (this allows having a subscribe link per membership type). How would that help with the token, though?
Comment #103
fagoOh, I think entity_reference does that already directly. I guess it only works if there is *no* label callback but a label key given.
Yes, I agree. Still, there is nothing stored in the group entity that isn't in the real group entity, not?
I'd imagine having relations like
node(group content) -> og membership -> node(group)
Whereas group metadata like "is the group enabled?" could be stored directly in group entity (node), as it is already the case for the active/pending state. Well, I'm just elaborating on the design, I know it's probably too late for such a drastic change.. :/
ad #1263588: Allow having multiple group-audience type fields
oh thanks for the pointer, very nice! :) Well, for tokens that could help making relations more predictable. If we could restrict the group entity type for a given membership type, we could do tokens like [node:membership:0:node:title] as we'd know the membership's group's entity is a node.
Comment #104
amitaibu> Oh, I think entity_reference does that already directly. I guess it only works if there is *no* label callback but a label key given.
I'll need to check -- does it query the key directly.
Anyway, I'm not opposed of deprecating the OG group entity. It think it was a nice idea at the time, but I see over time it just holds the group Id and label. Need to think on how to implement it, though ;)
Comment #105
amitaibuOpened issue about deprecating og group -- #1342632: Deprecate OG group entity
Comment #106
BrightBoldCan someone clarify what, if anything, currently works to get OG tokens? I've read through the issue twice and I still can't find a working solution. Fago says
but I was not successful using that token in Rules or Pathauto. I'm looking for a URL that includes the gid of the group content's group, and a rule that sends an e-mail when new group content is created saying "New content posted in ." But so far no token I have tried works. Is anyone doing this successfully?
Comment #107
jastraat CreditAttribution: jastraat commentedGiven that pathauto requires the token module, the only token support available in og comes from entity tokens, and the two modules are incompatible when a site has a large number of fields (http://drupal.org/node/1272560) - I just wrote my own module to create the tokens. The following only includes title and group path, but it could easily contain gid or whatever other token you'd like to use.
Comment #108
BrightBoldThanks jastraat. I tried your module but couldn't figure out what token names to use to make it work. However, pfrenssen's OG Token sandbox module (from #91) worked perfectly and totally meets my needs. (Although neither contains a gid token, that one seems to work fine with the default entity tokens (in Pathauto, I'm using [site:current-group:gid] for group content and [node:group:gid] for groups.))
Thanks for your prompt response!
Comment #109
mrfelton CreditAttribution: mrfelton commentedHas the [site:current-group:*] tokens been removed from the latest OG dev? This was working for me in 18bbcb389ea264fa6d703630d1e799b042cd2c3c not in the latest OG. I was previously using this in Rules to redirect to the group URL after deleting group content (by default when you delete content you end up on the site homepage, which is confusing for group managers as they then have to go and find their group again to continue what they were doing.
In Rules, I can also get a token which is node:og-membership:0:group:url which would usually work, but since this Rule is being fired after deleting content, node:og-membership:0:group:url doesn't seem to exist at that point (despite Rules presenting it as an option).
Can we get the [site:current-group:*] tokens back? They were very useful!
Comment #110
fizk CreditAttribution: fizk commented#91 rocks! Thanks BrightBold for the heads up.
Comment #111
jaarong CreditAttribution: jaarong commentedsubscribing to this issue. I use og:alias as a pathauto pattern for group content in D6 successfully, but can't find an equivalent (or really get any group tokens to work) in D7 pathauto 1.0 with OG 1.3
Comment #112
mrfelton CreditAttribution: mrfelton commentedLooks like the og_context module has some of these missing tokens now.
Would someone in the know be able to provide a little update as to what the status is here. After upgrading to the laste 2.x release, it seems like there is no way to get to a group from a group content node in rules. Where previously we could do stuff with node:og_membership, doesn't seem like there is any kind of equivalent any more.
I also tried adding a 'Entity has field' condition and adding the og_group_ref field, but even using that with node:og-group-ref:... doesn't allow me to get to an actual group.
What am I missing?
Comment #113
Jackinloadup CreditAttribution: Jackinloadup commentedmrfelton: try this issue #1421422: Port Rules integration to 7.x-2.x
Comment #114
justindodge CreditAttribution: justindodge commentedSo it seems that an equivalent of og:alias is still missing, is that correct?
I was able to utilize the module in comment #107 to provide the same functionality and it worked wonderfully, thanks!
Not quite sure where a good entry point in the code would be to get this token into the module, but it's very useful for building out group content that fits into a nice URL pattern.
Comment #115
donquixote CreditAttribution: donquixote commentedHi,
I want this for a new feature in Crumbs:
I would like to allow settings like:
Parent path for nodes of type "group":
groups
Parent path for nodes of type "group_event":
node/[node:group_nid]/events
etc.
Unfortunately, the
[node:group_nid]
(or sth equivalent) does not exist.Comment #116
donquixote CreditAttribution: donquixote commentedWow, entity_token seems to be a great help.
It provides e.g.
node/[node:group-audience:0:etid]
.So the breadcrumb settings could be:
Parent path for nodes of type "group":
groups
Parent path for nodes of type "group_event":
node/[node:group-audience:0:etid]/events
Parent path for nodes of type "group_discussion":
node/[node:group-audience:0:etid]/forum
Probably the same works for pathauto?
-------
It should be mentioned that entity_token says
group-audience
(hyphen), while og saysgroup_audience
(underscore).This looks awkward, if both show up in the token help.
It should also be noted that token help only shows
[node:group-audience:1:etid]
[node:group-audience:2:etid]
[node:group-audience:3:etid]
but not
[node:group-audience:0:etid]
Even though the :0: is the only one that works (for me).
Comment #117
bryancasler CreditAttribution: bryancasler commentedThis is great to know, thanks donquixote!
Comment #118
jaarong CreditAttribution: jaarong commentedYeah, that is good info, thanks. It did work in Pathauto, but it is the group id. If someone discovers how to get the group name in there, please post it.
Comment #119
JayDarnellHas a token for the group path been added to organic groups? I apologize if this seems like a silly and obvious question but in reading through this long discussion I didn't get a strong feeling either way. For me I have two group content types:
Facility - pathauto: facilities/[node:title]
Classroom - pathauto: classrooms/[node:title]
I also have a news content type that could be assigned to either a facility or a classroom. As a result I would like news items posted in a facility group to show up at "facilities/computer_lab/news/test_news_item" while a news item posted in a classroom might show up at "classrooms/mr_darnells_class/news/test_news_item". In order to do this I would need to capture the url for the group and append "/news/[node:title]" to it as the pathauto value for the news content type.
I found an example of this here: http://drupal.org/node/255335 but it seems really dated and I'm not sure the patch would work with 7.x-2.0-alpha3...
I also noted comment #107 above from jastraat but given the age of that comment and the fact that organic groups is currently in a state of flux I thought I should ask the group directly before I implement that custom module.
Comment #120
Kristen PolThanks @donquixote ! Based on #116, I knew that I should use 0 instead of 1 ;) (The notes on the deltas do mention that the index starts at 0... not sure why 0 items weren't included... bug?)
I created a pathauto pattern like:
[node:og-group-ref:0:title]/[node:title]
In order to have the group's title in the path.
Comment #121
dddbbb CreditAttribution: dddbbb commentedThank you, thank you, thank you @Kristen Pol. I was tearing my hair out trying to get the GID of a referenced group to appear using pathauto and OG 7.x-2.0-beta1. Your comment was the prompt I needed - I just needed to switch it to:
[node:og-group-ref:0:nid]
Question is, will this then break when I update to a later version of OG after this token business has been fixed?
Comment #122
dddbbb CreditAttribution: dddbbb commentedBTW, if you change a Groups Audience field from accepting multiple values to just a single value, using delta 0 in your token seems to break. I did exactly that and had to change:
[node:og-group-ref:0:nid]
to[node:og-group-ref:nid]
(removed0:
)PathAuto was freaking right out until I figured out that I'd have to make that amend. Hope that helps somebody.
Comment #123
Kristen PolThanks for the heads up, @dixhuit. I'll try to remember that one if I go from multiple=>single!
Comment #124
danoguru CreditAttribution: danoguru commentedI was also having hard time getting the groups path as the path prefix for group nodes. here my slight adaptation of og_token.module.
I added the path to the group array and returned it instead of label.
Comment #125
amitaibuI think we can close this, as it works fine for me and others (#122).
Comment #127
leoklein CreditAttribution: leoklein commentedBingo! I was using Custom Breadcrumbs with OG 7.2x and couldn't figure out the tokens. Finally!
Comment #128
lahode CreditAttribution: lahode commentedHi Leoklein
I wonder how you succeeded to use the code given in #124, because it uses the concept of OG 7.1 which is completely different from OG 7.2
Anyway, I rewrote the module to make it work with OG 7.2 and tested with success
http://drupal.org/node/1930132
Cheers
Comment #129
sassafrass CreditAttribution: sassafrass commentedThank-you danoguru and lahode. I used lahode's code for OG 7.2 and works like a charm. :-)
Comment #130
emjayess CreditAttribution: emjayess commentedNot working: `[node:og-group-ref:........]` tokens turning up empty. OG 2.7 w/og context and entity tokens present.
Comment #131
tanius CreditAttribution: tanius commented#128 works for me. For my variant of this which uses the group URL alias rather than the group's title in the token, see my answer here.