MyBB Hacks

Full Version: How to add a function or parse "slugs"?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Good!

I need help to add a function that converts strings in "slugs" function and have the write down, but do not know where to add that this is recognized by "Template Conditionals".

PHP Code:
function slugify($text) { 
  $text = preg_replace('~[^\\pL\d]+~u', '-', $text);
  $text = trim($text, '-');
  $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
  $text = strtolower($text);
  $text = preg_replace('~[^-\w]+~', '', $text);

  if (empty($text)) {
    return 'n-a';
  }

  return $text;
}


Any idea how to do this?

Greetings and thanks.

Can't be done with Template Conditionals, but PHP in Templates should work.

Or, if you have the function already included somewhere, and it's already reference-able globally across MyBB, and just want to be able to reference it from Template Conditionals, modify inc/plugins/phptpl_allowed_funcs.txt
Reference URL's