<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>register_modifier()</title> <meta name="generator" content="DocBook XSL Stylesheets V1.75.1"> <link rel="home" href="index.html" title="Smarty Manual"> <link rel="up" href="api.functions.html" title="Chapter 13. Smarty Class Methods()"> <link rel="prev" href="api.register.function.html" title="register_function()"> <link rel="next" href="api.register.object.html" title="register_object()"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr><th colspan="3" align="center">register_modifier()</th></tr> <tr> <td width="20%" align="left"> <a accesskey="p" href="api.register.function.html">Prev</a> </td> <th width="60%" align="center">Chapter 13. Smarty Class Methods()</th> <td width="20%" align="right"> <a accesskey="n" href="api.register.object.html">Next</a> </td> </tr> </table> <hr> </div> <div class="refentry" title="register_modifier()"> <a name="api.register.modifier"></a><div class="titlepage"></div> <div class="refnamediv"> <h2>Name</h2> <p>register_modifier() — dynamically register modifier plugin</p> </div> <div class="refsect1" title="Description"> <a name="id3104155"></a><h2>Description</h2> <code class="methodsynopsis"><span class="type">void </span><span class="methodname">register_modifier</span>(<span class="methodparam"><span class="type">string </span><span class="parameter">name</span></span>,<br> <span class="methodparam"><span class="type">mixed </span><span class="parameter">impl</span></span>);</code><p> Pass in the template modifier name, followed by the PHP function that it implements it. </p> <p> The php-function callback <em class="parameter"><code>function</code></em> can be either: </p> <div class="itemizedlist"><ul class="itemizedlist" type="disc"> <li class="listitem"><p> A string containing the function <em class="parameter"><code>name</code></em> </p></li> <li class="listitem"><p> An array of the form <code class="literal">array(&$object, $method)</code> with <code class="literal">&$object</code> being a reference to an object and <code class="literal">$method</code> being a string containing the method-name </p></li> <li class="listitem"><p> An array of the form <code class="literal">array($class, $method)</code> with <code class="literal">$class</code> being the class name and <code class="literal">$method</code> being a method of the class. </p></li> </ul></div> <p> </p> <div class="example"> <a name="id3105236"></a><p class="title"><b>Example 13.24. register_modifier()</b></p> <div class="example-contents"> <pre class="programlisting"> <?php // let's map PHP's stripslashes function to a Smarty modifier. $smarty->register_modifier('ss', 'stripslashes'); ?> </pre> <p>In the template, use <code class="literal">ss</code> to strip slashes.</p> <pre class="programlisting"> <?php {$var|ss} ?> </pre> </div> </div> <br class="example-break"><p> See also <a class="link" href="api.unregister.modifier.html" title="unregister_modifier()"><code class="varname">unregister_modifier()</code></a>, <a class="link" href="api.register.function.html" title="register_function()"><code class="varname">register_function()</code></a>, <a class="link" href="language.modifiers.html" title="Chapter 5. Variable Modifiers">modifiers</a> section, <a class="link" href="plugins.html" title="Chapter 16. Extending Smarty With Plugins">extending Smarty with plugins</a> and <a class="link" href="plugins.modifiers.html" title="Modifiers">creating plugin modifiers</a>, </p> </div> </div> <div class="navfooter"> <hr> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"> <a accesskey="p" href="api.register.function.html">Prev</a> </td> <td width="20%" align="center"><a accesskey="u" href="api.functions.html">Up</a></td> <td width="40%" align="right"> <a accesskey="n" href="api.register.object.html">Next</a> </td> </tr> <tr> <td width="40%" align="left" valign="top">register_function() </td> <td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td> <td width="40%" align="right" valign="top"> register_object()</td> </tr> </table> </div> </body> </html>