| 148 |
lars |
1 |
default {#language.modifier.default}
|
|
|
2 |
=======
|
|
|
3 |
|
|
|
4 |
This is used to set a default value for a variable. If the variable is
|
|
|
5 |
unset or an empty string, the given default value is printed instead.
|
|
|
6 |
Default takes the one argument.
|
|
|
7 |
|
|
|
8 |
Parameter Position Type Required Default Description
|
|
|
9 |
-------------------- -------- ---------- --------- ---------------------------------------------------------------
|
|
|
10 |
1 string No *empty* This is the default value to output if the variable is empty.
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
<?php
|
|
|
14 |
|
|
|
15 |
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
|
|
|
16 |
$smarty->assign('email', '');
|
|
|
17 |
|
|
|
18 |
?>
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
Where template is:
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
{$articleTitle|default:'no title'}
|
|
|
26 |
{$myTitle|default:'no title'}
|
|
|
27 |
{$email|default:'No email address available'}
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
Will output:
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
Dealers Will Hear Car Talk at Noon.
|
|
|
35 |
no title
|
|
|
36 |
No email address available
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
See also the [default variable handling](#tips.default.var.handling) and
|
|
|
41 |
the [blank variable handling](#tips.blank.var.handling) pages.
|