Drupal 7: How can I create a key / value field (or a group of fields, if possible)?

Say I'm creating application documentation. When creating a content type for functions, I have a text field for the name, a field for a general description, and a couple of other basic things. Now I need something to store the function arguments. Ideally, I would like to enter them as key-value pairs or only two related fields, which can then be repeated as many times as necessary for this function. But I can’t find a way to do this.

The closest I got is a deferred multi- group field module , which says that wait for CCK3, which has not yet released alpha as far as I can tell, and on the project page which there is no obvious mention of this multi-group functionality. I also checked the CCK request queue and don't think I saw it there.

Is there a real way to do this, I don’t see? Viable includes "you think it wrong and do X instead." I have examined the use of the “Long Texts and Resume” field, but it smells like a hacker, and I don’t know if I will tune in to side effects. I am new to Drupal.

+4
source share
3 answers

There is a module http://drupal.org/project/field_collection , but it is not ready yet. Right now you need to realize your essence to do this: (not easy).

+3
source

I’m not sure how well it will work, because currently it is a little bigger (for example, it forces groups to be grouped into categories and the keys must be predefined), but you might want to take a look at http://drupal.org/project/properties .

+2
source

You can create these key-value fields yourself: create 2 regular fields that can be added as often as needed.

So you have x fields for keys and x for values. If this is just for you or other people, this may work just fine, but the usability is very ugly.

If you need to extract fields from a function in order to display it correctly in the page template, you should use a different approach. Write a function with its arguments in the CCK field and extract them as necessary in the template. Arguments are always (depending on the language) in () , and different arguments are divided by,, so their separation will be quite simple.

0
source

Source: https://habr.com/ru/post/1334812/


All Articles