Ask a newbie question, how to write judgment statements in template files
PhpNewer
PhpNewer 2018-06-12 22:43:48
0
8
1437

<?php

$nologin =

<<<nologin

<!-- 未登陆显示-->

<ul class="nav navbar-nav">

  <li><a href="{:url('user/login')}">登录 <span class="sr-only">(current)</span></a></li>

  <li><a href="{:url('user/reg')}">注册</a></li>

</ul>

nologin;


$areadylogin =

<<<areadyLogin

<!-- 已登陆显示 -->

<li class="dropdown">

  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><img src="__STATIC__/images/index/meinv.jpg" class="img-circle" width="18px"/></a>

  <ul class="dropdown-menu">

    <li id="info"><a href="#">个人信息</a></li>

    <li><a href="#">退出</a></li>

  </ul>

</li>

areadylogin;


if(Session::get('user_id')){

  echo $areadylogin;

}else{

  echo $nologin;

}

?>

以上是基于bootstrap在php里面实现根据用户是否登陆在导航栏出现不同的显示。未登陆时,显示“登陆 注册”按钮,登陆后显示头像下拉菜单,以及退出按钮。


我的问题来了?

在模版文件中,tp框架下怎么在首页模版顶部显示上述功能呢?用javasript来写吗?java有没有类似php定界符之类的东西。


求大神指教。

PhpNewer
PhpNewer

reply all(4)
小鳥濤

Are you from Band of Brothers?

  • reply How can you see it?
    PhpNewer author 2018-06-26 14:57:00
小叮当

<if condition="条件">...<else/>...</if>

ATAO

<empty name="name">name is empty<else /> name is not empty</empty> In fact, it is in the manual. When using the framework, you must learn to read the documentation yourself.

  • reply Embarrassing, I just asked because I couldn’t find a method in the TP template.
    PhpNewer author 2018-06-13 11:29:27
JAVA FANS

This requires the use of a framework


  • reply It is the tp framework used. How to write judgment statements in templates?
    PhpNewer author 2018-06-12 22:54:12
  • reply <if condition="条件">Show avatar<else/>Show login|Register</if>
    小叮当 author 2018-06-13 12:02:30
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template