| Recommend this page to a friend! |
| Packages of Michael Beck | Xoops 2.5 | htdocs/xoops_lib/vendor/smarty/smarty/docs/designers/language-builtin-functions/language-function-insert.md | Download |
|
|||||||||||||||||||||
{insert}> Note
>
>
| Attribute Name | Required | Description |
|----------------|----------|----------------------------------------------------------------------------------|
| name | Yes | The name of the insert function (insert_ ExamplesLet's say you have a template with a banner slot at the top of the page. The banner can contain any mixture of HTML, images, flash, etc. so we can't just use a static link here, and we don't want this contents cached with the page. In comes the {insert} tag: the template knows \#banner\_location\_id\# and \#site\_id\# values (gathered from a config file), and needs to call a function to get the banner contents.
In this example, we are using the name "getBanner" and passing the parameters \#banner\_location\_id\# and \#site\_id\#. Smarty will look for a function named insert\_getBanner() in your PHP application, passing the values of \#banner\_location\_id\# and \#site\_id\# as the first argument in an associative array. All {insert} function names in your application must be prepended with "insert_" to remedy possible function name-space conflicts. Your insert\_getBanner() function should do something with the passed values and return the results. These results are then displayed in the template in place of the {insert} tag. In this example, Smarty would call this function: insert_getBanner(array("lid" => "12345","sid" => "67890")); and display the returned results in place of the {insert} tag.
The Smarty object is passed as the second argument. This way you can
reference and modify information in the Smarty object from within the
If no PHP script can be found Smarty is looking for a corresponding insert plugin. > Note
>
> It is possible to have portions of the template not cached. If you
> have caching turned on, See also |