Use the IF tag instead of the empty label, because there is an else case.
登 录
注 册
{$Think.session.user}
It is possible to write the above observations.
But, condition Part I have tried several, why not?
1)
Or
2)
Or
3)
Or
4)
What I want to know is: Why not the above four ways?
If I do not want to use $_session, want to use Think.session.user words, condition part should write?
Reply content:
Use the IF tag instead of the empty label, because there is an else case.
登 录
注 册
{$Think.session.user}
It is possible to write the above observations.
But, condition Part I have tried several, why not?
1)
Or
2)
Or
3)
Or
4)
What I want to know is: Why not the above four ways?
If I do not want to use $_session, want to use Think.session.user words, condition part should write?
Empty also has else to use AH
You can try this:
{$Think.session.user}
登 录
注 册
TP has an empty label to determine if it is null.
You can judge the presence of the session ("user") in the controller, pass the user parameter to the template in the session, and do not pass the user parameter, in the template, determine whether the $user variable exists.
As in action
// TP中,session是默认开启的,通过session("?sessionName")的方式进行判断,session存在就返回true,反之就返回falseif(session("?user")){ $this->assign("user",session("user"));}
Then judge in the template
已登录的html code
未登录的html