Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
display()
2
 
3
displays the template
4
 
5
Description
6
===========
7
 
8
void
9
 
10
display
11
 
12
string
13
 
14
template
15
 
16
string
17
 
18
cache\_id
19
 
20
string
21
 
22
compile\_id
23
 
24
This displays the contents of a template. To return the contents of a
25
template into a variable, use [`fetch()`](#api.fetch). Supply a valid
26
[template resource](#resources) type and path. As an optional second
27
parameter, you can pass a `$cache_id`, see the [caching
28
section](#caching) for more information.
29
 
30
PARAMETER.COMPILEID
31
 
32
 
33
    <?php
34
    include(SMARTY_DIR.'Smarty.class.php');
35
    $smarty = new Smarty();
36
    $smarty->setCaching(true);
37
 
38
    // only do db calls if cache doesn't exist
39
    if(!$smarty->isCached('index.tpl')) {
40
 
41
      // dummy up some data
42
      $address = '245 N 50th';
43
      $db_data = array(
44
                   'City' => 'Lincoln',
45
                   'State' => 'Nebraska',
46
                   'Zip' => '68502'
47
                 );
48
 
49
      $smarty->assign('Name', 'Fred');
50
      $smarty->assign('Address', $address);
51
      $smarty->assign('data', $db_data);
52
 
53
    }
54
 
55
    // display the output
56
    $smarty->display('index.tpl');
57
    ?>
58
 
59
 
60
 
61
Use the syntax for [template resources](#resources) to display files
62
outside of the [`$template_dir`](#variable.template.dir) directory.
63
 
64
 
65
    <?php
66
    // absolute filepath
67
    $smarty->display('/usr/local/include/templates/header.tpl');
68
 
69
    // absolute filepath (same thing)
70
    $smarty->display('file:/usr/local/include/templates/header.tpl');
71
 
72
    // windows absolute filepath (MUST use "file:" prefix)
73
    $smarty->display('file:C:/www/pub/templates/header.tpl');
74
 
75
    // include from template resource named "db"
76
    $smarty->display('db:header.tpl');
77
    ?>
78
 
79
 
80
 
81
See also [`fetch()`](#api.fetch) and
82
[`templateExists()`](#api.template.exists).