7

I recently downloaded the Features module and was so glad over how smoothly I now can export functionality from dev to prod. But now when I'm trying to create a second feature I'm getting conflicts because I already used a lot of the same field bases in my first feature.

What can I do to resolve this? Are you not suppose to be able to use the same fields in different features? It doesn't seem right that I should have to define as many fields for "body text" that I have features, or image fields for that matter. Those fields could and should be shared right?

What are my options here?

7

Say you have two Features, and one field that is used in both Features, then you only need to export the field base ONCE.

This is why I generally have a "controller" Feature that contains field bases, update hooks etc, and then for every other Feature I export the field instance, and then add a dependency on my controller feature.

Basically, you are right - you don't need to export the field bases every time, just export them once and then add dependencies.

  • ^ This seems a bit ropey, if you need any further clarification please let me know and I'll see if I can expand. – Chapabu Aug 14 '13 at 8:20
  • Yes I just started doing something like this. I'm now removing the field bases from my created feature, and adding them in a new "Master field bases feature", which I'll be adding as a dependency on future features that share fields. This is what you mean right? Also, this seems like a better idea than not defining the field bases in a "master feature", since then future feature dependencies will be all over the place. – Johan Dahl Aug 14 '13 at 8:29
  • 1
    Yeah, that's kinda what I do. My "controller" Feature always serves other purposes as well though. For example, if during my feature development, I change some module settings, I put them in a hook_update_N implementation in the controller feature's .install file. All of my dependencies are resolved with the controller feature, and all of my "sub-features" depend on the controller. This means that all module dependencies are resolved in one single place, as opposed to 5/6/different Features....does that make sense? – Chapabu Aug 14 '13 at 8:31
  • While we are on this issue, how do I set up my dependencies to the "master feature"? I have now created a master feature with the base fields, and my other feature holds the fields instances instead. Do I add dependencies myself somewhere or does this work automaticly? I dont see any options. – Johan Dahl Aug 14 '13 at 8:34
  • 1
    Ah, that's a completely different question I'm afaid. Two good places to start are the documentation for hook_update_N or the hook-update-n tag on this site :) – Chapabu Aug 14 '13 at 8:42

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.