Closed (fixed)
Project:
Examples for Developers
Version:
7.x-1.x-dev
Component:
Node Example
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
26 Nov 2012 at 09:32 UTC
Updated:
2 Apr 2013 at 20:45 UTC
Jump to comment: Most recent file
Comments
Comment #1
mile23Ahh, nice catch. That's a documentation error. node_example.install was removed not long ago.
A patch would be nice.. Care to give it a go? http://drupal.org/patch
Comment #2
mile23Comment #3
marvin_b8 commentedComment #4
mile23The test shows as postponed right now, but I'll take a chance and commit this one. :-)
http://drupalcode.org/project/examples.git/commitdiff/c3e56b6c655843263e...
Thanks!
Comment #6
mile23Comment #7
mile23#3: 1850530-3.patch queued for re-testing.
Comment #9
mile23Hmm. Not sure why the patch failed to apply in the test. It worked locally.
Comment #10
mile23Comment #12
mbrakken commentedCan I ask for a clarification of this fix? It seems backwards to me, but I might not know what I'm talking about. The initial question was about node_example.install missing, despite a reference to it. The fix entailed removing the reference to that file rather than replacing the file.
Everything else I've seen on the question of creating content types in code relies on a .install file except for the Examples module. The difference, from what I can tell, lies in inserting content types into the database either via hook_install in a .install file or via hook_node_type_insert in the .module file. Core's standard.install file does it the first way, while this module does it the second way. Is the method used here the preferred/better one? If so, why?
Is there a reason why .install was removed entirely? Again, every tutorial I've found talks of using the .install file, so I'm sure I'm not the only one who is confused on this.
Thanks.
Comment #13
mile23In order to make a node-based content type, all you have to do is implement hook_node_info(). Drupal does everything else.
In Drupal 6, that was not the case, and you had to manage the database yourself, starting with hook_install() and hook_schema().
In our example, we use hook_node_type_insert() in order to attach fields to our node type.
This has a few advantages over using hook_install(), the most important of which is that we know the content type exists before we attach the fields to it.
The example documentation explains a bunch of this: http://api.drupal.org/api/examples/node_example%21node_example.module/gr...
Comment #14
mbrakken commentedThanks a lot! I've looked around the API docs many times but hadn't seen the examples project in there until now. Given that I was reading different things from different sources, I wasn't sure what was cannon. This will now be super useful.