0

I want to programmatically do two things:

  1. Replace the default multiline Description field of taxonomy term with my own, plain text, single line field. I mean - to visually replace - I understand this is an entity property and all I can do is to hide it and create another, plain text field.

  2. Populate the vocabulary through taxonomy_term_save() - putting the description strings into the newly created field.

Would anyone be kind and provide a skeleton of code to achieve it?

1

This is really two questions.

For the first, I would use hook_taxonomy_term_view to alter $build['description']['#markup'], like so:

function custom_taxonomy_term_view_alter(&$build) {
  $build['description']['#markup'] .= '<p> And this is more stuff.<p>';
}

For the second, taxonomy_term_save() can take a description field as described on the API docs page.

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.