Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
All is in the title!
It would be great if the selected filter(s) for the node type could apply to all text fields added with Content Construction Kit and not only to the body field...
Comment | File | Size | Author |
---|---|---|---|
#21 | filterbynodetype.module.patch | 4.32 KB | ricflomag |
#17 | filterbynodetype.cck_.patch | 7.13 KB | okeedoak |
#12 | filterbynodetype.module.patch (patch) | 4.15 KB | ricflomag |
#12 | filterbynodetype.module.patched.test (whole file) | 5.05 KB | ricflomag |
#10 | filterbynodetype.module.patch | 4.04 KB | ricflomag |
Comments
Comment #1
adrien.gibrat CreditAttribution: adrien.gibrat commentedHere is the patch... my first contribution to drupal! cool, I'm proud, but exhausted (haven't sleep this night)...
Just replace the filterbynodetype_form_alter function by this one:
Comment #2
Crell CreditAttribution: Crell commentedInteresting addition. Can you roll a proper patch so that I can look at it? Code pasted into the text box here is not useful for reviewing. Thanks.
http://drupal.org/diffandpatch
I did note one problem right off, though. Never put values directly into the query string. Use the %d/%s-based escaping in db_query().
Comment #3
adrien.gibrat CreditAttribution: adrien.gibrat commentedThe final version with module check and syntax highlight + a attachment version
Comment #4
adrien.gibrat CreditAttribution: adrien.gibrat commentedThanks for the advice about escaping in db_query()...
And sorry for the patch but i can't do it now: the http://unxutils.sourceforge.net/UnxUtils.zip link is broken... and i'm not very confortable with patch to do it :(
I join the corrected version, you should be able to test it.
Comment #5
adrien.gibrat CreditAttribution: adrien.gibrat commentedTanks to this video, putty and a shared host, I finally build a patch with diff!
Comment #6
ricflomag CreditAttribution: ricflomag commentedThanks adrian, works great. I had wrote a patch myself, but it was not as smart as yours!
Hope to see it released soon...
Comment #7
ricflomag CreditAttribution: ricflomag commentedWell, finally it did not work so well... The issues were:
Here is a patch against 1.x-dev (18/06/07) to address these issues.
There is another unsolved issue: using firefox (and i guess any gecko based browser), the #default_value may not work, because the browser auto-fills the form with previously cached values, ignoring the checked='checked' attribute. The only workaround i can think of would be to set the default values using javascript when the page is loaded. but this is a drupal-wide matter...
Comment #8
ricflomag CreditAttribution: ricflomag commentedPosting the whole filterbynodetype.module file too.
Comment #9
Crell CreditAttribution: Crell commentedRight, so, I finally got a chance to look over the patch in #7. *sigh* Unfortunately, there are a couple of problems:
- You're still putting variable text directly into the query string. That is a security hole. You need to use proper placeholders instead of putting $type directly into the query, and to be clean you should do the same for 'text'. The semi-colon is also not needed.
- You're not restoring the help text for filter text, at least not if there's only one filter remaining. It should still show the help text, just as it does on a normal node.
- Please give _filterbynodetype_form_alter_helper() a proper docblock header, not an inline comment. While you're at it, a more descriptive name than "helper" would be good, too. :-)
- Inline comments should be in sentence format, per coding standards. (Capitalize first word, end with a period, use a complete sentence.)
Comment #10
ricflomag CreditAttribution: ricflomag commentedThanks for your review Crell,
Six months ago, it's a long time, i didn't even remember what was that all about ;) I tried to address your comments, the only thing i've left undone is to restore the help text for the filters, as i am not sure how to do this well.
Here is the new patch. I have not tested it though. Please feel free to finish the job :-)
Regards,
Ric.
Comment #11
Crell CreditAttribution: Crell commentedThe original module did so; you can probably just copy its code (which I admit is nasty, since this whole module is a nasty hack). Sorry, I don't have time today to forward-port that snippet myself. :-(
Comment #12
ricflomag CreditAttribution: ricflomag commentedHere it is, but once again, NOT TESTED. Please anyone interested in using it, report your experience :-)
Comment #13
Crell CreditAttribution: Crell commentedPlease test a patch before posting it. Also, there is no need to repost the entire file. That is useless for review purposes and just wastes disk space. Also, files ending in .test are reserved for unit test scripts. :-)
Comment #14
ricflomag CreditAttribution: ricflomag commentedSorry Crell, i'm doing my best to help and address your comments about the patch, but i don't have much time, like you. I could have say "Sorry, i won't do it" instead of making and posting the patch. I hope you understand.
I've posted the whole file for two reasons: people often have problems or don't know how to apply a patch, so i anticipate their request to be able to download the whole file; and the patch is so important compared to the size of the original file, that it's easier to review the whole file.
Regards.
Comment #15
okeedoak CreditAttribution: okeedoak commentedUsing the "filterbynodetype.module.patched.test (whole file)" seems to work. Good job and thank you!
A couple of minor issues:
Again these are minor issues.
I'm running Drupal 5.7 and CCK 5.x-1.7
Comment #16
okeedoak CreditAttribution: okeedoak commentedFound a conflict with Site Notes: http://drupal.org/project/sitenotes Trying to create new Site Note (5.x-1.2) results in the White Screen of Death (WSOD). How can I debug this?
Here's the error:
Fatal error: Call to undefined function _filterbynodetype_form_alter_helper() in filterbynodetype.module on line 35
Tested Site Node creation with the standard 5.x-1.x-dev, 2007-Jun-18 version and there is no conflict.
Comment #17
okeedoak CreditAttribution: okeedoak commentedI've taken the code from the 5.x-1.x-dev, 2007-Jun-18 version that deals with non CCK types and combined it with the changes in the patch to get a working version.
Results:
Also changed the weight of the menu item to 0 so it appears in alphabetical order with the other items in the Site Configuration menu.
I wonder if other modules that provide their own content types are also unaffected?
Comment #18
Crell CreditAttribution: Crell commentedThis module assumes the node form structure defined by node.module for admin-created types. Contrib modules that define node types need to follow the same structure or this module will have no (useful) effect. That is easy to do, however, by simply making the following the start of the form:
That gives you the same structure and conditionals as admin-created nodes for free, which is nice.
I'm going out of town for a few days so won't be able to look at #17 until next week. If anyone else wants to give it a whirl and report back, please do! The main thing to remember is that the help filter text needs to be preserved.
Comment #19
okeedoak CreditAttribution: okeedoak commentedTested the patched version from #17 with the new 2008-May-07 Dev version of Site Notes (http://drupal.org/project/sitenotes) which incorporates the changes mentioned in #18. Everything seems to work fine: Site Notes now respects the filter settings of Filter by node type and even the help filter text is displayed correctly. I tested the filter help text:
Thanks for your post in #18 on how to get the integration process between the two modules to work. (I just passed on the information, I didn't code the changes.)
Comment #20
okeedoak CreditAttribution: okeedoak commentedRegarding the preservation of Input Format help text in CCK content types with the patch from #17:
Number two is a bug. Maybe someone who is more qualified than myself could look at the code to see where the problem lies.
One suggestion: on pages with many text areas and only one allowed input format the help text would quickly becomes redundant and clutter the page. If there was a choice on the Site configuration page to show or not show the help text that would be great.
Comment #21
ricflomag CreditAttribution: ricflomag commentedI've had some time to test the patch i made on #12, correct the error reported by okeedoak on #16 and also change the menu weight to 0.
@okeedoak: The difference with your work on #17, as far as i can see, is that the function _filterbynodetype_form_alter_add_filter() is now used twice, preventing code redundancy. (In the patch i posted on #12, the first call to the function was misspelled and led to the error).
Comment #20 is still to address, sorry to let some work undone.
Comment #22
Summit CreditAttribution: Summit commentedSubscribing, greetings, Martijn
Comment #23
Crell CreditAttribution: Crell commentedAfter much consideration, I've decided that this functionality does not belong in filterbynodetype. Limiting what input formats are allowed on a given field should be the responsibility of the field and the module that provides it, that is, node.module for the body and text.module for CCK textfields. filterbynodetype exists only because node.module is too dumb to do so, and that won't change in a stable release. CCK, however, moves faster so we should implement that functionality in CCK directly, not via form_alter black magic.
KarenS, yched, I turn this over to you to figure out how best to implement it. :-)
Comment #24
open-keywords CreditAttribution: open-keywords commented@Crell
that's all probably good decisions, but this feature is really needed and what is going to happen for users of D5 and CCK 1.x ?? (looks assigned to 6.x-2.x !) ??
Comment #25
markus_petrux CreditAttribution: markus_petrux commentedPlease, search for Better Formats module.