1

This is a follow-up on, but not a duplicate of, Programmatically creating a content type with file field in a custom module.

As suggested by Tenken in a comment to the OP of that question, it is easy to do this by using the core FieldUI module to create the fields, and then then use Features to export the fields to a custom "Feature" module.

You can then install the "Feature" module as any other module that implements a custom content type, but you need to have Features installed for it to work.

I want to use the FieldUI and Features to create a custom content type module, but the module should be stand-alone (i.e. not depend on Features for (re)creation of the content type).

Is this doable? Or is Features a dead end in my use-case? I.e.: If I want a stand-alone module, I must create it from scratch.

And if it makes sense to use Features, what do I need to do in order to transform the "Features" module into a stand-alone one?

(I've searched for similar questions, but not found an answer that describes how you make the generated "Features" stand-alone.)

2

The features eco-system simply implements certain hook functions (like hook_field_info for example). It wraps these core api functions with import/export code.

When you export your content type using Features you can inspect what it creates -- besides a mymodule.install and mymodule.module files.

By examining the hooks the features implements for your exported content type -- there is nothing stopping you from copying/renaming these exported function definitions and migrating them to a new module's hook_install() function. Thus, creating a new content type which you used Features to create the building block(s).

  • Sorry, I meant that in the simplest sense a Module is a folder with a .info file. When you export just a content type + it's fields using Features it makes the minimum drupal hooks to represent that data. That does not necessarily include a hook_schema function because Drupal fields are de-normalized and re-used across content types. – tenken Nov 29 '14 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.