Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > 3ca7e0e5486da714e98ac79af09ca745 > files > 124

php-smarty2-doc-2.6.28-2.mga4.noarch.rpm

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Inserts</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.1">
<link rel="home" href="index.html" title="Smarty Manual">
<link rel="up" href="plugins.html" title="Chapter 16. Extending Smarty With Plugins">
<link rel="prev" href="plugins.resources.html" title="Resources">
<link rel="next" href="appendixes.html" title="Part IV. Appendixes">
</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">Inserts</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="plugins.resources.html">Prev</a> </td>
<th width="60%" align="center">Chapter 16. Extending Smarty With Plugins</th>
<td width="20%" align="right"> <a accesskey="n" href="appendixes.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="Inserts">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="plugins.inserts"></a>Inserts</h2></div></div></div>
<p>
     Insert plugins are used to implement functions that are invoked by
     <a class="link" href="language.function.insert.html" title="{insert}"><code class="varname">{insert}</code></a>
     tags in the template.
    </p>
<div class="funcsynopsis">
<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table">
<tr>
<td><code class="funcdef">string <b class="fsfunc">smarty_insert_name</b>(</code></td>
<td>
<var class="pdparam">$params</var>, </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>
<var class="pdparam">&amp;$smarty</var><code>)</code>;</td>
<td> </td>
</tr>
</table>
<div class="paramdef-list">
<code>array <var class="pdparam">$params</var></code>;<br><code>object <var class="pdparam">&amp;$smarty</var></code>;</div>
<div class="funcprototype-spacer"> </div>
</div>
<p>
     The first parameter to the function is an associative array of
     attributes passed to the insert.
    </p>
<p>
     The insert function is supposed to return the result which will be
     substituted in place of the <code class="varname">{insert}</code> tag in the
     template.
    </p>
<div class="example">
<a name="id3128506"></a><p class="title"><b>Example 16.11. insert plugin</b></p>
<div class="example-contents"><pre class="programlisting">

&lt;?php
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     insert.time.php
 * Type:     time
 * Name:     time
 * Purpose:  Inserts current date/time according to format
 * -------------------------------------------------------------
 */
function smarty_insert_time($params, &amp;$smarty)
{
    if (empty($params['format'])) {
        $smarty-&gt;trigger_error("insert time: missing 'format' parameter");
        return;
    }
    return strftime($params['format']);
}
?&gt;

     </pre></div>
</div>
<br class="example-break">
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="plugins.resources.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="plugins.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="appendixes.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Resources </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> Part IV. Appendixes</td>
</tr>
</table>
</div>
</body>
</html>