How smarty displays variables and arrays.
By the way php
side has been set what value to return to the template, here we introduce only the treatment of smarty in the template
as work on the front side.
View the variables that are passed across the template.
First, it is a simple display of variables that are neither arrays nor objects.
If there is a variable of $arena_rank
, just come with {}
as follows.Now the template
Ranking {$arena_rank}
Show arrays across a template
First, check the value that is being passed, similar to var_dump
in php.
Click here for details [Smarty]Display the variable array of smarty templates
{$rank_list|@debug_print_var}
The contents of $rank_list
were as follows when i checked the contents in the following debug_print_var
introduced the other day.
0 "Yamada" 1 "Tanaka" 2 "Nakayama"
For example, if you want to display the first Yamada in the above example, it will be as follows.
There are several ways to write.
{$rank_list[0]} {$rank_list.0}
The same is true for associative arrays.
Let's say the values that have been passed over the $user
are as follows:
name "Yamada" By mail "aaa@aaa.com" Tel "000-0000-0000"
If you want to see the mail address
{$user.mail}
You can also use the key of a variable when displaying an array.
{$rank_list.$arena_rank}
The name displayed by the number in the arena_rank
changes.
It is an introduction of the basic display method.
Smarty Recommended Books
Smarty had only old books, but the following are recommended for getting started.
Smarty PHP Template Programming and Applications