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.
Issue: Currently when providing replacements using token.module, ctools only uses the first set of tokens returned. For node tokens, this eliminates any field tokens added by CCK.
Fix: Instead of using reset() to only grab the first set of tokens returned by token_get_list(), ctools should iterate over each token category so that any additional tokens provided by other modules (such as CCK) will be added to the list.
Comment | File | Size | Author |
---|---|---|---|
#17 | ctools-cck-token-context-argument-ayalon-943896.patch | 3.2 KB | ayalon |
#12 | workinprogressCCKtokens.png | 109.71 KB | Letharion |
#8 | ctools-token-context-943896-8.patch | 3.51 KB | joshuajabbour |
#1 | ctools-943896.patch | 3.83 KB | joshuajabbour |
Comments
Comment #1
joshuajabbour CreditAttribution: joshuajabbour commentedThe attached patch fixes this issue for node, user, and token (global) converters.
Comment #2
deleuje CreditAttribution: deleuje commentedI was just about to abandon Panels once again for template files.
This patch saved me.
Thanks!
Comment #3
james.williams CreditAttribution: james.williams commented+1
Comment #4
spuky CreditAttribution: spuky commentedThis Patch helpt to get CCK fields in Panels context...
Comment #5
joshuajabbour CreditAttribution: joshuajabbour commentedif you've reviewed and applied this patch and not found any bugs, please mark RTBC
Comment #6
bludrop CreditAttribution: bludrop commentedI applied the patch, however I can't figure out how to include CCK fields in my panels content. The "substitutions" list doesn't include any of the CCK field tokens, it just has the few %node keywords.
How can I use a keyword to display content from CCK fields?
Comment #7
Jim Kirkpatrick CreditAttribution: Jim Kirkpatrick commented+1
Comment #8
joshuajabbour CreditAttribution: joshuajabbour commentedrerolled patch
Comment #9
Jim Kirkpatrick CreditAttribution: Jim Kirkpatrick commented#8 Works well for me, thanks Joshua.
Comment #10
Letharion CreditAttribution: Letharion commentedDoesn't the output get rather messy though?
For example when I have three different vocabularies that I can tag a node with, I get:
Name of terms vocabulary
Name of terms vocabulary
Name of terms vocabulary
Kinda hard to tell which selection comes from which vocabulary. And I get a lot of those identical triplets.
I'll see if I can work it out.
Comment #11
merlinofchaos CreditAttribution: merlinofchaos commentedWe might need to do this in 2 phases. Go ahead and properly open it up so that all tokens are available, and then allow token categorization. Though I dunno if the necessary text will be available.
Comment #12
Letharion CreditAttribution: Letharion commentedtoken_get_list() does not provide enough information by itself to properly identify the options.
However, just removing reset() will provide something looking like the attached screenshot.
Comment #13
Letharion CreditAttribution: Letharion commentedI just realized that my approach does not play well with the panels ui.
Comment #14
Itangalo CreditAttribution: Itangalo commentedsubscribing
Comment #15
joshuajabbour CreditAttribution: joshuajabbour commentedYes, as per #12, token.module itself doesn't provide enough metadata to make useful labels. It def makes the UI confusing, but it is better to have a confusing UI, or a bunch of unavailable data? I don't know...
Comment #16
Itangalo CreditAttribution: Itangalo commented@joshuajabbour: A confusing UI has always been preferred over unavailable data in the Drupal world, as far as I know. And I'm all in favour. :-)
Comment #17
ayalon CreditAttribution: ayalon commentedAt the moment, it is not possible to pass a CCK Value (for example the year of a date field) to a view.
The proposed patch has some problems if you have multiple cck fields with the same field type. You will have duplicate entries and cannot determine the according field.
My patch adds the field name. Now you can easily determine the correct token.
Comment #18
Anonymous (not verified) CreditAttribution: Anonymous commented+1
Comment #19
james.williams CreditAttribution: james.williams commentedAnyone interested in getting this functionality for D7 should take a look at #691078: Field tokens. It's currently at nearly 300 comments though! The patch for Token module in http://drupal.org/node/691078#comment-4139738 looks to be the best progress so far. Note that CTools uses the core token system in D7.
Comment #20
Jim Kirkpatrick CreditAttribution: Jim Kirkpatrick commentedPatch in #17 works like a dream on toast. Please commit!
Comment #21
PierreMarcel CreditAttribution: PierreMarcel commentedI second the patch on #17 it works great so far, but still on a staging site... after applied it list all the cck fields available in panels, great job Ayalon thanks for the patch!
Comment #22
Dave ReidRe #19: That shouldn't be necessary for CTools in D7 now that we have properly nestable tokens. People cannot and should not just create arbitrary token categories that still mean 'node' in D7.
Comment #23
sketman CreditAttribution: sketman commentedI applied patch in post #17 but it did not work for me. No new tokens are available in Panels as contexts. It was my first patching experience, however. Even I did not get any error message during, I could do something wrong.
Guys, dont wanna bothering, but could you somebody attach here patched node.inc file please?
Thanks in advance...
Comment #24
rootworkPatch worked for me as well. Would love to see this get applied.
@sketman: The patch actually modifies three files: node.inc, user.inc and token.inc. Maybe that's the trouble you're running into?
Comment #25
Summit CreditAttribution: Summit commentedHi, Is this patch also committed to D7 please?
Would love to use the token-replacement also in D7.
Thanks a lot in advance for your reply in advance.
Greetings, Martijn
Comment #26
letapjar CreditAttribution: letapjar commentedThe patch in #17 works great - please commit to the next point release.
Comment #27
merlinofchaos CreditAttribution: merlinofchaos commentedCommitted and pushed.