title: Using Smarty Modifier
body: <p>I found this Smarty modifier on smartys website that is a post to convert bbcode in to html but i can't find or it don't say what the syntax is to use it for example.</p>
  
  <pre><code>{$bbcode_here|bbcode2html}
  </code></pre>
  
  <p>Could someone please tell or show me how to use this Smarty modifier is below.</p>
  
  <pre><code>function smarty_modifier_bbcode2html($message) {
    $preg = array(
            '/(?&lt;!\\\\)\[color(?::\w+)?=(.*?)\](.*?)\[\/color(?::\w+)?\]/si'   =&gt; "&lt;span style=\"color:\\1\"&gt;\\2&lt;/span&gt;",
            '/(?&lt;!\\\\)\[size(?::\w+)?=(.*?)\](.*?)\[\/size(?::\w+)?\]/si'     =&gt; "&lt;span style=\"font-size:\\1\"&gt;\\2&lt;/span&gt;",
            '/(?&lt;!\\\\)\[font(?::\w+)?=(.*?)\](.*?)\[\/font(?::\w+)?\]/si'     =&gt; "&lt;span style=\"font-family:\\1\"&gt;\\2&lt;/span&gt;",
            '/(?&lt;!\\\\)\[align(?::\w+)?=(.*?)\](.*?)\[\/align(?::\w+)?\]/si'   =&gt; "&lt;div style=\"text-align:\\1\"&gt;\\2&lt;/div&gt;",
            '/(?&lt;!\\\\)\[b(?::\w+)?\](.*?)\[\/b(?::\w+)?\]/si'                 =&gt; "&lt;span style=\"font-weight:bold\"&gt;\\1&lt;/span&gt;",
            '/(?&lt;!\\\\)\[i(?::\w+)?\](.*?)\[\/i(?::\w+)?\]/si'                 =&gt; "&lt;span style=\"font-style:italic\"&gt;\\1&lt;/span&gt;",
            '/(?&lt;!\\\\)\[u(?::\w+)?\](.*?)\[\/u(?::\w+)?\]/si'                 =&gt; "&lt;span style=\"text-decoration:underline\"&gt;\\1&lt;/span&gt;",
            '/(?&lt;!\\\\)\[center(?::\w+)?\](.*?)\[\/center(?::\w+)?\]/si'       =&gt; "&lt;div style=\"text-align:center\"&gt;\\1&lt;/div&gt;",
  
            // [code] &amp; [php]
            '/(?&lt;!\\\\)\[code(?::\w+)?\](.*?)\[\/code(?::\w+)?\]/si'           =&gt; "&lt;div class=\"bb-code\"&gt;\\1&lt;/div&gt;",
            '/(?&lt;!\\\\)\[php(?::\w+)?\](.*?)\[\/php(?::\w+)?\]/si'             =&gt; "&lt;div class=\"bb-php\"&gt;\\1&lt;/div&gt;",
            // [email]
            '/(?&lt;!\\\\)\[email(?::\w+)?\](.*?)\[\/email(?::\w+)?\]/si'         =&gt; "&lt;a href=\"mailto:\\1\" class=\"bb-email\"&gt;\\1&lt;/a&gt;",
            '/(?&lt;!\\\\)\[email(?::\w+)?=(.*?)\](.*?)\[\/email(?::\w+)?\]/si'   =&gt; "&lt;a href=\"mailto:\\1\" class=\"bb-email\"&gt;\\2&lt;/a&gt;",
            // [url]
            '/(?&lt;!\\\\)\[url(?::\w+)?\]www\.(.*?)\[\/url(?::\w+)?\]/si'        =&gt; "&lt;a href=\"http://www.\\1\" target=\"_blank\" class=\"bb-url\"&gt;\\1&lt;/a&gt;",
            '/(?&lt;!\\\\)\[url(?::\w+)?\](.*?)\[\/url(?::\w+)?\]/si'             =&gt; "&lt;a href=\"\\1\" target=\"_blank\" class=\"bb-url\"&gt;\\1&lt;/a&gt;",
            '/(?&lt;!\\\\)\[url(?::\w+)?=(.*?)?\](.*?)\[\/url(?::\w+)?\]/si'      =&gt; "&lt;a href=\"\\1\" target=\"_blank\" class=\"bb-url\"&gt;\\2&lt;/a&gt;",
            // [img]
            '/(?&lt;!\\\\)\[img(?::\w+)?\](.*?)\[\/img(?::\w+)?\]/si'             =&gt; "&lt;img src=\"\\1\" alt=\"\\1\" class=\"bb-image\" /&gt;",
            '/(?&lt;!\\\\)\[img(?::\w+)?=(.*?)x(.*?)\](.*?)\[\/img(?::\w+)?\]/si' =&gt; "&lt;img width=\"\\1\" height=\"\\2\" src=\"\\3\" alt=\"\\3\" class=\"bb-image\" /&gt;",
            // [quote]
            '/(?&lt;!\\\\)\[quote(?::\w+)?\](.*?)\[\/quote(?::\w+)?\]/si'         =&gt; "&lt;div&gt;Quote:&lt;div class=\"bb-quote\"&gt;\\1&lt;/div&gt;&lt;/div&gt;",
            '/(?&lt;!\\\\)\[quote(?::\w+)?=(?:&amp;quot;|"|\')?(.*?)["\']?(?:&amp;quot;|"|\')?\](.*?)\[\/quote\]/si'   =&gt; "&lt;div&gt;Quote \\1:&lt;div class=\"bb-quote\"&gt;\\2&lt;/div&gt;&lt;/div&gt;",
            // [list]
            '/(?&lt;!\\\\)(?:\s*&lt;br\s*\/?&gt;\s*)?\[\*(?::\w+)?\](.*?)(?=(?:\s*&lt;br\s*\/?&gt;\s*)?\[\*|(?:\s*&lt;br\s*\/?&gt;\s*)?\[\/?list)/si' =&gt; "\n&lt;li class=\"bb-listitem\"&gt;\\1&lt;/li&gt;",
            '/(?&lt;!\\\\)(?:\s*&lt;br\s*\/?&gt;\s*)?\[\/list(:(?!u|o)\w+)?\](?:&lt;br\s*\/?&gt;)?/si'    =&gt; "\n&lt;/ul&gt;",
            '/(?&lt;!\\\\)(?:\s*&lt;br\s*\/?&gt;\s*)?\[\/list:u(:\w+)?\](?:&lt;br\s*\/?&gt;)?/si'         =&gt; "\n&lt;/ul&gt;",
            '/(?&lt;!\\\\)(?:\s*&lt;br\s*\/?&gt;\s*)?\[\/list:o(:\w+)?\](?:&lt;br\s*\/?&gt;)?/si'         =&gt; "\n&lt;/ol&gt;",
            '/(?&lt;!\\\\)(?:\s*&lt;br\s*\/?&gt;\s*)?\[list(:(?!u|o)\w+)?\]\s*(?:&lt;br\s*\/?&gt;)?/si'   =&gt; "\n&lt;ul class=\"bb-list-unordered\"&gt;",
            '/(?&lt;!\\\\)(?:\s*&lt;br\s*\/?&gt;\s*)?\[list:u(:\w+)?\]\s*(?:&lt;br\s*\/?&gt;)?/si'        =&gt; "\n&lt;ul class=\"bb-list-unordered\"&gt;",
            '/(?&lt;!\\\\)(?:\s*&lt;br\s*\/?&gt;\s*)?\[list:o(:\w+)?\]\s*(?:&lt;br\s*\/?&gt;)?/si'        =&gt; "\n&lt;ol class=\"bb-list-ordered\"&gt;",
            '/(?&lt;!\\\\)(?:\s*&lt;br\s*\/?&gt;\s*)?\[list(?::o)?(:\w+)?=1\]\s*(?:&lt;br\s*\/?&gt;)?/si' =&gt; "\n&lt;ol class=\"bb-list-ordered,bb-list-ordered-d\"&gt;",
            '/(?&lt;!\\\\)(?:\s*&lt;br\s*\/?&gt;\s*)?\[list(?::o)?(:\w+)?=i\]\s*(?:&lt;br\s*\/?&gt;)?/s'  =&gt; "\n&lt;ol class=\"bb-list-ordered,bb-list-ordered-lr\"&gt;",
            '/(?&lt;!\\\\)(?:\s*&lt;br\s*\/?&gt;\s*)?\[list(?::o)?(:\w+)?=I\]\s*(?:&lt;br\s*\/?&gt;)?/s'  =&gt; "\n&lt;ol class=\"bb-list-ordered,bb-list-ordered-ur\"&gt;",
            '/(?&lt;!\\\\)(?:\s*&lt;br\s*\/?&gt;\s*)?\[list(?::o)?(:\w+)?=a\]\s*(?:&lt;br\s*\/?&gt;)?/s'  =&gt; "\n&lt;ol class=\"bb-list-ordered,bb-list-ordered-la\"&gt;",
            '/(?&lt;!\\\\)(?:\s*&lt;br\s*\/?&gt;\s*)?\[list(?::o)?(:\w+)?=A\]\s*(?:&lt;br\s*\/?&gt;)?/s'  =&gt; "\n&lt;ol class=\"bb-list-ordered,bb-list-ordered-ua\"&gt;",
            // escaped tags like \[b], \[color], \[url], ...
            '/\\\\(\[\/?\w+(?::\w+)*\])/'                                      =&gt; "\\1"
  
    );
    $message = preg_replace(array_keys($preg), array_values($preg), $message);
    return $message;
  }
  </code></pre>
  
  <p>thanks</p>