Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
documentation
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
12 Aug 2010 at 10:37 UTC
Updated:
18 Nov 2010 at 19:10 UTC
Jump to comment: Most recent file
Comments
Comment #1
avpadernoSee http://api.drupal.org/api/function/node_type_form_submit/6, where Drupal variables used from form fields present in the content type edit form are renamed.
Variables are not automatically deleted from Drupal core when a content type is deleted.
Comment #2
jhodgdonGood catch. This does need an update.
Comment #3
avpadernoI can change the example implementation myself; which implementation should I use as example? comment_node_type()?
Comment #4
jhodgdonYeah, I guess so, although it only illustrates the 'delete' $op. If we could find an example that did all the ops, that would be better, but I didn't see one in core... The other option would be to make a mish-mash like:
Comment #5
avpadernobook_node_type() has code for the update operation. I was going to avoid to show the code for that operation to make clear that it is not anymore needed when Drupal variables are used in the content type form.
It would be possible to add a sentence to explain that.
Comment #6
jhodgdonI think it makes sense to include a sample of update to illustrate why you might remotely need it, along with a comment explaining that you don't usually (as you have described above).
Comment #7
avpadernoif it would not be for the comment to add, I would do the change myself; comments in the code are not my strength. :-)
For the rest, I would take the code from two different modules, and add a comment before each snippets saying from where the code comes from.
If I correctly recall, the example code for
hook_theme()was changed by me to include code coming from a core module different from the module used for the existing code to show all the theme declaration cases.Comment #8
jhodgdonHere's what I would put in the comment (or something similar):
Most modules will not need the update or insert operations, because form fields you add to the node type editing form will be automatically saved as variables. For instance, if you add a field called 'my_module_foo' to content type 'machine_name', its value will be saved as variable 'my_module_foo_machine_name' (and if the machine name is updated, the variables will be updated appropriately). Here is an example where you do need an update operation (from the book module), because the simple default case doesn't cover what needs to be done.
Comment #9
avpadernoComment #10
jhodgdonI think I would take the part starting with "Here is an example" and make that into a code comment rather than keeping it in the docblock header. I would put it right after the comment you have in the code that says // book.module now.
Also, as a style point, there should be a blank line before the first @param.
Comment #11
dleatham commentedA suggestion in relation to #8 above... I'm trying to implement a system where, when an instance of content_type_A is created, instances of content_type_B and content_type_C are created and the two are linked back to content_type_A.
I've seen a fair number of posts in the forums where others are struggling with this type of use-case. I'd like to see an example of how the 'insert' $op can be used to catch the insertion of one type of content so that instances of other content types can be created/linked.
Appreciate your efforts at making Drupal better.
Comment #12
jhodgdonI've applied the above patch, slightly modified, to the contrib repository.