Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Are there any automatic fields value generation from node body F.E.?
Are there any automatic fields value generation from node body F.E.?
Comments
Comment #1
valthebaldNot yet. Any idea of how do you see it?
Comment #2
podarokjob_queue i think...
after node creating make it as background task via job_queue and auto-filling via cron
Comment #3
valthebaldThe question here is not HOW to fill meta fields (IMO the best way is to react to node insert/update), but WHAT values to use.
Obviously, it is impossible and meaningless to copy body or any other field into meta, so - how do you specify pattern for description/keywords?
Comment #4
robcarrCan't tokens be used? That's how the D6 Nodewords module worked (didn't it?).
Comment #5
valthebaldMakes sense.
Probably token usage will not require any code change :)
I will check that.
Comment #6
valthebaldRegretfully, field subsystem of D7 does not support tokens "natively" (see broad discussion at http://drupal.org/node/691078). There are some workarounds, please read discussion.
I postpone this issue until we have some solution in core token or token contrib.
Correct me if I'm wrong, but currently I don't see any other option :(
Comment #7
POVYLAZZZ CreditAttribution: POVYLAZZZ commentedMaybe you could give some hints how to set them programaticly?
Comment #8
valthebaldI'm afraid that I don't understand your question.
Little bit more details please?
Comment #9
POVYLAZZZ CreditAttribution: POVYLAZZZ commentedSorry I meant field values.
I guess I could make use of function which check`s if field is empty. And write a switch based on field name. Inside switch I would put something like that:
$node->field_y[$node->language][0]['value'] = $node->field_x[$node->language][0]['value'];
Does the node_save function is necessary after it? And how to get for example term names? The $node->terms contains only an array of term id`s and I need names.
Comment #10
valthebaldEasy way to achieve this (no programming): declare field as required, set it's default value - in any new page you will have values prepopulated!
Comment #11
valthebaldComment #12
Johnny vd Laar CreditAttribution: Johnny vd Laar commentedI've done this via Rules:
The problem is that the summary field should not contain too much data
Comment #13
Johnny vd Laar CreditAttribution: Johnny vd Laar commentedOk I modified it such that it creates a truncated version with tags stripped:
Comment #14
andypostI think the module's schema should be extended with small int field use_defaults!
So each entity get a record of meta-field, this approach gives ability to reflect on changing default values without updating data in DB.
Default values could be customized within field settings on instance level
EDIT: Another way is to extent hook_field_is_empty() to report each time that field is not empty
Comment #15
valthebaldMore correct status is 'needs work' I guess :)
You have only suggestion, not a ready patch...
Comment #16
andypostSure, I'll try to test this on holidays
Comment #17
valthebaldFrom now on, please post comments on autofill in #1122486: Support for tokens in field values