Is it possible to add an option to remove the space between two or more words? Eg "one two three" into "onetwothree".
Thank you for this great module!

Comments

BarisW’s picture

I don't feel like adding a lot of formatting options to the module. What I could to is add a hook so that a module developer could alter the formatting himself.

Something like:

<?php
MYMODULE_termcase_format_term_alter(&$output, $term) {
  $output = drupal_replace(' ', '', $output);
}
?>

Would that work?

ItangSanjana’s picture

@BarisW that did the trick! Thanks again!

BarisW’s picture

Hi Itang,

I only proposed to implement this, I didn't do it yet.
So what exactly did the trick? :)

Did you modify the module code to get this working? If so; a patch would be welcome.

ItangSanjana’s picture

No, for now I need this at least for the front end.
Your idea has been enlightening me to use it in custom views display :)
But hopefully in the near future I can make a patch for this.
Thanks.

BarisW’s picture

Status: Active » Fixed

I've added a hook to alter the terms, like this:

<?php
/**
 * Alter string conversion before it is saved.
 *
 * @param string $converted_string
 *   The string that is about to be saved after the conversion.
 *
 * @param string $original_string
 *   The original unaltered string.
 *
 * @param int $case
 *   Static that defines the given case formatting. Possible options:
 *     TERMCASE_NONE
 *     TERMCASE_UCFIRST
 *     TERMCASE_LOWERCASE
 *     TERMCASE_UPPERCASE
 *     TERMCASE_PROPERCASE
 */
function hook_termcase_convert_string_alter(&$converted_string, $original_string, $case) {
  $converted_string = drupal_str_replace(' ', '', $converted_string);
}
?>
ItangSanjana’s picture

This is awesome thank you so much! With drupal_str_replace() it thorw Fatal error: Call to undefined function drupal_str_replace() .. so I use the old str_replace() as follows.

function my_module_termcase_convert_string_alter(&$converted_string, $original_string, $case) {
  $converted_string = str_replace(' ', '', $converted_string);
}

Thanks again!

ItangSanjana’s picture

BarisW’s picture

Ah my fault, thanks for the patch. Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.