You are here

function signup_id_safe in Signup 6.2

Same name and namespace in other branches
  1. 5.2 signup.module \signup_id_safe()
  2. 5 signup.module \signup_id_safe()
  3. 6 signup.module \signup_id_safe()
  4. 7 signup.module \signup_id_safe()

Converts an arbitrary string into something safe to use for a CSS id.

Stolen wholesale from the Zen theme. ;)

See also

zen_id_safe()

1 call to signup_id_safe()
theme_signup_custom_data in theme/node.admin.inc
Renders custom signup user data into a human-readable format.

File

./signup.module, line 1485
The Signup module (http://drupal.org/project/signup) manages replies to nodes. In particular, it's good for event management. Signup supports sending reminder emails and automatically closing signups for nodes with a start time, via the Event…

Code

function signup_id_safe($string) {

  // Replace with dashes anything that isn't a-zA-Z, numbers, dashes, or
  // underscores.
  $string = drupal_strtolower(preg_replace('/[^a-zA-Z0-9_-]+/', '-', $string));

  // If the first character is not a-z, add 'id' in front.
  // Don't use ctype_alpha since it's locale aware.
  if (!ctype_lower($string[0])) {
    $string = 'id' . $string;
  }
  return $string;
}