1

I am making a custom field and would like to use other custom fields -- like the Link or Media fields -- inside it. Can I do this, and if so how do I determine what #type to include in my field definition?

For example, the pattern "Image + Linked Headline + Brief Description" happens frequently enough in my content that I am trying to create a custom field that combines these. But a lot of what I need already exists in both Link and Media plugins, and I'd rather not recreate that functionality if possible.

I have already tried using the Field Collection module for this, but can't because it does not support translation.

Edited

I think I have found my way around the Field Collection translation problem by switching to field translation instead of node translation. Field collection seems to be a little buggy there, especially for collections made prior to turning on entity translation, but so far it seems to be working.

A yes/no answer to this would still be interesting, though, for future custom-field development. The more I think about it, the more I think the answer is likely "no."

  • not really an answer for the question. But you could follow this link drupal.org/node/1683784 . this has the translation issue of the field collection and could get some hints as to how to solve it – Mohammed Shameem Jan 24 '13 at 17:21
  • Thanks, Mohammed. I found that earlier, too, but I wasn't eager to take this particular site into production with a patched beta module. – John Williams Jan 24 '13 at 17:27
1

Please let me know if I'm misinterpreting your question — essentially, you're asking how to group up fields of content that appear frequently together on your Drupal site? Without using Field Collection... hmmm...

Well, first potential option is the Field Group module. However, it may not be exactly what you want seeing as how you mentioned Field Collection. It may be worth looking into though. Not sure it supports translation though.

The next potential option I see is changing the actual Image entity through the File Type interface provided by the Media module. At this screen, you can actually adjust the Image entity to contain extra fields. In doing this, all you would need then is place the Image field in your content type. The user uploading an image via this Media field would then be prompted to add the linked headline and a brief description after uploading the image.

Because the Media module documentation does an AWESOME job of explaining how to modify an Image entity, here is the documentation page about managing/editing file types — scroll down to the start of the section "Manage the Display of Images (Manage File Types)". After adding these fields to your Image entity (or a new entity), you'll be able to manage the display like you would for a content type.

  • Thanks. I was specifically asking if/how to use the Field API do handle this, although I'm certainly open to other translation-friendly alternatives. I believe field group visually organizes a set of fields within a content type, but does not let you add multiple values of those fields. That's what Field Collection buys you, but at the expense of translatability. Modifying the Image entity is an interesting idea, but I can think of cases where the same image might be needed with different links / descriptions. Not sure how likely that is, though. – John Williams Jan 24 '13 at 17:56
  • Would it possible to have multiple image entities? I rarely if ever work with APIs or PHP but it seems like you could potentially create another Image entity or use some conditional formatting in the provided Image entity to handle different situations. I'm very interested in seeing what you come up with! Keep me posted. :) I see something like #type and instantly think div id and move on but that must have been the clue that you were looking for how to manipulate the field API. My apologies. – Courtface Jan 24 '13 at 19:19
  • Oh, and the tag you put at the bottom of your question. I'm new to this site. :/ – Courtface Jan 24 '13 at 19:23

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.