In node_example.module at line 56, you mention "@see node_example.install". The node_example.install file seems to be missing. I faintly remember that in an older version (probably Feb 2012), the module pack included this file.

regards

CommentFileSizeAuthor
#3 1850530-3.patch409 bytesmarvin_b8

Comments

mile23’s picture

Category: support » task
Status: Active » Needs work
Issue tags: +Novice

Ahh, 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

mile23’s picture

Priority: Major » Normal
marvin_b8’s picture

Status: Needs work » Needs review
StatusFileSize
new409 bytes
mile23’s picture

The 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!

Status: Needs review » Needs work

The last submitted patch, 1850530-3.patch, failed testing.

mile23’s picture

Status: Needs work » Fixed
mile23’s picture

Status: Fixed » Needs review
Issue tags: -Novice

#3: 1850530-3.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Novice

The last submitted patch, 1850530-3.patch, failed testing.

mile23’s picture

Hmm. Not sure why the patch failed to apply in the test. It worked locally.

mile23’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mbrakken’s picture

Can 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.

mile23’s picture

In 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...

mbrakken’s picture

Thanks 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.