1

I'm using the Termcase module to make all the taxonomy terms ucwords in a specific vocabulary.

enter image description here

It also has the option: Convert the existing terms in this vocabulary immediately

It works for making the term UPPERCASE, lowercase but doesn't work for ucwords although it has the ucwords (propercase) option (first character of each word uppercase).

And if needed this is the related code part in termcase.module:

case TERMCASE_PROPERCASE;
  $words = explode(' ', $original_string);
  foreach ($words as $key => $word) {
    $words[$key] = drupal_ucfirst($word);
  }
  $converted_string = implode(' ', $words);
  break;


What should I do to make all the existing terms ucwords?

1
  • Directly applying the ucwords option didn't work and I found a way to do what I wanted. At first, I converted all the terms to lowercase and then to ucwords and it worked. If there isn't any better solution to this, I will use that as a solution.
    – herci
    Nov 25 '14 at 22:47
1

Not a perfect solution but this is the way I used to solve the problem while converting terms to ucwords:

If all the letters of terms are lowercase then applying ucwords is working correctly.

  1. Go to the vocabulary page you wanted to convert terms (admin/structure/taxonomy/VOCABULARY_NAME).
  2. Select the "Convert all characters to lowercase" option.
  3. Enable the "Convert the existing terms in this vocabulary immediately."
  4. Save and then it will updates (converts) all the terms to lowercase.
  5. Then select the "Convert the first character of each word to uppercase" option.
  6. Save and then it will updates (converts) all the terms to ucwords.

Done.


original -> step 1-4 -> step 5-6

  • my first term -> my first term -> My First Term
  • MY SECOND TERM -> my second term -> My Second Term
  • My Third Term -> my third term -> My Third Term
  • mY FourTH TErm -> my fourth term -> My Fourth Term

It works correctly.



(If you directly apply "Convert the first character of each word to uppercase" option to these terms above, the results would become:

original -> ucwords

  • my first term -> My First Term
  • MY SECOND TERM -> MY SECOND TERM
  • My Third Term -> My Third Term
  • mY FourTH TErm -> MY FourTH TErm

Doesn't work correctly if the words has uppercase letters. So do as I mentioned above (steps 1-6).

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.