search

Home  >  Q&A  >  body text

Ask a newbie question, how to write judgment statements in template files

<?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定界符之类的东西。


求大神指教。

PhpNewerPhpNewer2356 days ago1411

reply all(8)I'll reply

  • TAO

    TAO2018-06-13 14:39:28

    Are you from Band of Brothers?

    reply
    0
  • PhpNewer

    How can you see it?

    PhpNewer · 2018-06-26 14:57:00
  • 小叮当

    小叮当2018-06-13 12:03:40

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

    reply
    0
  • ATAO

    ATAO2018-06-13 09:32:01

    <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
    0
  • PhpNewer

    Embarrassing, I just asked because I couldn’t find a method in the TP template.

    PhpNewer · 2018-06-13 11:29:27
  • J**A FANS

    J**A FANS2018-06-12 22:45:37

    This requires the use of a framework


    reply
    0
  • PhpNewer

    It is the tp framework used. How to write judgment statements in templates?

    PhpNewer · 2018-06-12 22:54:12
    小叮当

    Show avatarShow login|Register

    小叮当 · 2018-06-13 12:02:30
  • Cancelreply