I use taxonomy to divide a website in sections, e.g. youth, children etc.
It would be very very nice to have [node:workbench_access:name] available as a token to determine the patterns for URL aliasing.
Els the contributor has to fill in a separate field, with is redundant. Besides I do not want them to be able to do this since they should be able to only add content to their own section.
I understand workbench_access provides in this, except that I need somehow the URL-pattern.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | 1237284-workbench-access-tokens.patch | 18.88 KB | dave reid |
| #15 | 1237284-workbench-access-tokens.patch | 14.13 KB | dave reid |
| #11 | 1237284-workbench-access-tokens.patch | 3.57 KB | dave reid |
| #5 | workbench_access.tokens.inc_.txt | 3.53 KB | agentrickard |
Comments
Comment #1
agentrickardSeems reasonable. Shouldn't be very hard.
Patch?
Comment #2
Fonkel commentedI'm not a coder, so I'm not able to write a patch (if that's what you mean :-)
Comment #3
agentrickardThat was my hope. This shouldn't take very long though, and should be ready for the 1.0 release.
Comment #4
Fonkel commentedThanks a lot! Sorry that I can't do this for you guys! I think you did a great job with this module!
Comment #5
agentrickardHere's a patch. Well, not really a patch. Just rename the attached file
workbench_access.tokens.incand drop it in the workbench_access directory.Seems to work. Could (maybe) use a test?
Comment #6
dave reidWill give this a test plus write some tests for this tomorrow!
Comment #7
Fonkel commentedThanks for posting this file.
What I've found out is that in the case of taxonomy used for URL aliasing, I can use the token for taxonomy-term-name in the URL.
I have not found this yet in the tokens that workbench exposes?
Comment #8
agentrickardIt's there. If you're using taxonomy as the scheme, it should be [node:workbench_access].
Comment #9
Fonkel commentedGreat, it does work very well!
While testing this, I came to another request:
Let's say I have several events for the different sections of the website.
I used to filter these results in the view using contextual filter (argument) of section.
This was possible with the taxonomy-field.
Is it possible to expose the Workbench Access field as an argument? Or at least as a filter, so the content can be filtered down to a certain section?
Comment #10
agentrickardYou mean this #1191484: Workbench Access Views Contextual Filters, I assume. Otherwise, please open a new issue.
Comment #11
dave reidHere's the proper patch. To review the changes:
1. Only two tokens are needed: workbench-access-sections (section names keyed by access ID), and workbench-access-type. Using the array token type we now get [node:workbench-access-sections:keys] rather than having to implement [node:workbench_access_id].
2. Created a re-usable workbench_access_get_node_sections() functions to return a node's access section names keyed by access ID.
3. Fixed variable_get('workbench_access')'s default is actually 'taxonomy'.
4. Fixed [node:workbench-accesss-type] returns the machine name and not the actual name.
Just need to write some tests for this.
Comment #12
dave reidComment #13
agentrickardDon't we need the 'access_id' for people not using Token module?
Comment #14
dave reidI would think that most people (including the reporter) are most interested in the section names and not the IDs. I think for the purposes here it's perfectly reasonable to say "You can install the Token module to access the IDs as token to access [node:workbench-access-sections:keys]."
As a token system maintainer I'd prefer to avoid duplicating tokens wherever possible. If we did provide a [node:workbench-access-ids] token then it would not only be duplicating [node:workbench-access-sections:keys] but also adding more tokens and data to the token tree because of the additional token.
Comment #15
dave reid- Revised patch that moves/renames [node:workbench-access-type] to [site:workbench-access-scheme] as the access scheme is site-wide and not node-based.
- Also creates a access scheme token type so you can do [site:workbench-access-scheme:machine-name].
- Adds a [user:workbench-access-sections] token for the sections assigned to a user account.
- Includes tests for all tokens.
Todos:
- Add some tests for multiple-section nodes/users.
Comment #16
agentrickardNiiiice.
Comment #17
dave reidTests added for multi-section nodes and users.
Found a bug in that you cannot do the following:
The problem is that workbench_access_node_save() fails if
$node->workbench_access_scheme['access_scheme']);is not defined - which is true for any node loaded via node_load() since that property is added in the forms themselves.There is also a variable mis-match. workbench_access_node_load() adds the section IDs in $node->workbench_access, while the form submission contains the IDs in $node->workbench_access_ids. A temporary measure has been added in workbench_access_node_save() until this can be resolved (separate issue will be filed).
Tests should be run against the full suite of tests to ensure I didn't regress anything because of the workbench_access_node_load() and workbench_access_node_save() changes.
Comment #18
dave reidConfirmed tests pass: 94 passes, 0 fails, 0 exceptions.
Comment #19
agentrickardLet's commit this and then fix the other issue in a follow-up. It's non critical, even with the sloppy fix (and I say sloppy because the save function is badly designed, not because the fix is).
Comment #20
dave reid#17 has been committed to 7.x-1.x:
http://drupalcode.org/project/workbench_access.git/commit/760ab89
http://drupalcode.org/project/workbench_access.git/commit/6501f03
Thanks all for the testing and feedback.