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.
Token filter wasn't able to replace CCK field values so I created the attached patch that makes it possible. Maybe a nice addition to add to the next release?
Comment | File | Size | Author |
---|---|---|---|
#11 | token_filter.730078-3.patch | 1.88 KB | Grayside |
#8 | token_filter.patch | 1.5 KB | markwittens |
token_filter.patch | 1.58 KB | markwittens |
Comments
Comment #1
markwittens CreditAttribution: markwittens commentedMaybe convenient for other users to provide a small manual:
Usage:
[token node [[cck-field-name]] ]
Example:
To put the contents of the field "field_customfield" in the text you can use the following token: [token node field_customfield-raw]
Comment #2
pvhee CreditAttribution: pvhee commentedThanks for the patch.
I saw the code uses the global variable '$_customfilter_code_vars;'. From what I could find, it is a variable of the module Custom Filter (issue http://drupal.org/node/259819 as you mentioned in the patch). Does this mean you require dependency of this module? Can you explain a bit more about how your patch is supposed to work in absence of that module?
Comment #3
markwittens CreditAttribution: markwittens commentedThere's no dependency on the Custom filter module, the only link is the name of the variable and that actually should be renamed to something else to prevent this kind of confusion in the future. My bad, I should have reviewed my code after copy-pasting :-)
Comment #4
WhenInRome CreditAttribution: WhenInRome commentedThanks!
Comment #5
mpisano CreditAttribution: mpisano commentedThanks its works great!!!
Comment #6
newToo CreditAttribution: newToo commentedI'm trying to create a cck text field that allows me to use tokens to insert the node's url... would this module be used for that? I don't seem to have any options to add tokens to the text field.
Comment #7
pvhee CreditAttribution: pvhee commented@markwittens: Could you roll out a new patch of #0 with suggestions from #3?
Comment #8
markwittens CreditAttribution: markwittens commentedHere's the patch with the suggestion from #3 in it.
Comment #9
Hobbes-2 CreditAttribution: Hobbes-2 commentedHum, could you tell me when this patch will be in the dev version ???
thanks!
Comment #10
ckwon CreditAttribution: ckwon commentedhello,
thanks for this nice patch. i searched this function for hours ;).
There is only a little problem. Replacement does not work if you preview a new node, only if you save it.
Comment #11
Grayside CreditAttribution: Grayside commented#10: That will be an ongoing problem with this module I expect. The problem is that Token Filter does not compute it's values from the node form, but rather by loading the current values from the database. Until you've saved the node, there are no current values.
Attached patch makes the code more clear about refusing NULL node objects, and makes sure the token syntax is left in place for preview.
Comment #12
imclean CreditAttribution: imclean commentedI'm looking at embedding CCK fields too. What's the advantage of this method over Linodef? http://drupal.org/project/linodef
Comment #13
MurzLinodef do the additional node_load, and in the key you must manually set the nid, but in this solution node loaded only once and cached in memory.
Comment #14
szantog CreditAttribution: szantog commentedAttached patch in #11 works perfect.
Comment #15
drecute CreditAttribution: drecute commentedpatch #11 does not work for me. It rather removes the
[token op]
string from the token and falls back to the default i.eglobal
anduser
Comment #16
jvieille CreditAttribution: jvieille commented#11 does not work.
In my case, nodeapi reports the OG group nid, not the node nid.
I don't use the hook function token_filter_nodeapi, I just changed this function:
Comment #17
darvanenDrupal 6 version is no longer supported. Please reopen this if you find it is relevant to Drupal 7 or 8.