<ul class="nav sidebar-menu">
<li {eq name="$url" value="index"}class="active"{/eq}>
<a href="{:url('/admin/index/index')}">
<i class="menu-icon glyphicon glyphicon-home"></i>
<span class="menu-text"> 后台首页 </span>
</a>
</li>
{volist name="nav" id="vo"}
<li>
<a href="#" class="menu-dropdown">
<i class="menu-icon fa {$vo.icon}"></i>
<span class="menu-text"> {$vo.title} </span>
<i class="menu-expand"></i>
</a>
<ul class="submenu">
{volist name="vo['children']" id="sub"}
<?php $sname=substr($sub['name'],0,strpos($sub['name'], '/')); ?>
<li {eq name="$url" value="$sname"}class="active"{/eq}>
<a href="/admin/{$sub.name}">
<span class="menu-text">{$sub.title}</span>
</a>
</li>
{/volist}
</ul>
</li>
{/volist}
</ul>
The above code arrangement is standard, but I don’t know why the tp5 loop is completely messed up
It becomes the following
<ul class="nav sidebar-menu">
<li >
<a href="/admin/index/index">
<i class="menu-icon glyphicon glyphicon-home"></i>
<span class="menu-text"> 后台首页 </span>
</a>
</li>
<li>
<a href="#" class="menu-dropdown">
<i class="menu-icon fa fa-dropbox"></i>
<span class="menu-text"> 产品 </span>
<i class="menu-expand"></i>
</a>
<ul class="submenu">
</ul>
</li>
<li>
<a href="#" class="menu-dropdown">
<i class="menu-icon fa fa-user"></i>
<span class="menu-text"> 管理员 </span>
<i class="menu-expand"></i>
</a>
<ul class="submenu">
<li >
<a href="/admin/user/lst">
<span class="menu-text">管理员列表</span>
</a>
</li>
<li class="active">
<a href="/admin/authrule/lst">
<span class="menu-text">权限列表</span>
</a>
</li>
<li >
<a href="/admin/authgroup/lst">
<span class="menu-text">用户组</span>
</a>
</li>
</ul>
</li>
<li>
<a href="#" class="menu-dropdown">
<i class="menu-icon fa fa-gear"></i>
<span class="menu-text"> 系统设置 </span>
<i class="menu-expand"></i>
</a>
<ul class="submenu">
<li >
<a href="/admin/conf/lst">
<span class="menu-text">配置列表</span>
</a>
</li>
<li >
<a href="/admin/conf/conf">
<span class="menu-text">配置项</span>
</a>
</li>
</ul>
</li>
</ul>
<li> and </ul> are not displayed according to the correct indentation. Although the page is not affected, it is very confusing when viewing the source code.
First of all, what you write here is a template language. The TP background is to further convert it into PHP code and then execute it. During the process of converting PHP, the generated code is completely different from the code you see. There may be a lot more. Or less. Some spaces and so on are ignored, and some have extra spaces and line breaks.
So, the code given to the browser will become what you see, mainly because of the inconsistency between spaces and line breaks.
Finally, the source code is not for others to see, the code in your editor is. No matter how messy it is, the browser just needs to recognize it. You can look at some websites and all the HTML codes are squeezed together because they have been compressed. But it doesn't matter, so don't worry about it.