| 148 |
lars |
1 |
registerResource()
|
|
|
2 |
|
|
|
3 |
dynamically register resources
|
|
|
4 |
|
|
|
5 |
Description
|
|
|
6 |
===========
|
|
|
7 |
|
|
|
8 |
void
|
|
|
9 |
|
|
|
10 |
registerResource
|
|
|
11 |
|
|
|
12 |
string
|
|
|
13 |
|
|
|
14 |
name
|
|
|
15 |
|
|
|
16 |
Smarty\_resource
|
|
|
17 |
|
|
|
18 |
resource\_handler
|
|
|
19 |
|
|
|
20 |
Use this to dynamically register a [Resource plugin](#resources) with
|
|
|
21 |
Smarty. Pass in the `name` of the Resource and the object extending
|
|
|
22 |
Smarty\_Resource. See [template resources](#resources) for more
|
|
|
23 |
information on how to setup a function for fetching templates.
|
|
|
24 |
|
|
|
25 |
> **Note**
|
|
|
26 |
>
|
|
|
27 |
> A resource name must be at least two characters in length. One
|
|
|
28 |
> character resource names will be ignored and used as part of the file
|
|
|
29 |
> path, such as `$smarty->display('c:/path/to/index.tpl');`
|
|
|
30 |
|
|
|
31 |
> **Note**
|
|
|
32 |
>
|
|
|
33 |
> Prior to Smarty 3.1 `registerResource()` accepted an array of callback
|
|
|
34 |
> functions. While this is still possible for backward compatibility
|
|
|
35 |
> reasons, it is strongly discouraged as callback functions have been
|
|
|
36 |
> deprecated as of Smarty 3.1.
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
<?php
|
|
|
40 |
$smarty->registerResource('mysql', new Smarty_Resource_Mysql());
|
|
|
41 |
?>
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
See also [`unregisterResource()`](#api.unregister.resource) and the
|
|
|
46 |
[template resources](#resources) section.
|