Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to add a function or parse "slugs"?
hasaezs Offline
Junior Member
**
Posts: 1
Joined: Nov 2014
Post: #1
How to add a function or parse "slugs"?
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:
1
2
3
4
5
6
7
8
9
10
11
12
13
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.

11-14-2014 09:33 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
How to add a function or parse "slugs"? - hasaezs - 11-14-2014 09:33 AM

 Standard Tools
Forum Jump: