Home  >  Article  >  Backend Development  >  How to use thinkPHP's Html template tags

How to use thinkPHP's Html template tags

不言
不言Original
2018-06-06 16:13:583044browse

This article mainly introduces how to use Html template tags in thinkPHP. It has a certain reference value. Now I share it with you. Friends in need can refer to it

If we need a select drop-down menu now item, then we can do this in ThinkPHP

Note: Before using tags such as c7040750bcf6a21804e263a965d67cfb, you must introduce the TP tag library: 24fe360d7691f7a0a3f90108ae1bba3b
If we need a select drop-down menu item now, we can do this in ThinkPHP.

1. Obtain data in the method of the Action controller, for example:

##Copy code The code is as follows:

public function mylist(){ 
$user = new Model(‘User'); 
$list = $user->getField(‘id,username'); 
$this->assign(‘users',$list); 
$this->display(); 
}

2. Import the tag library into the template page and write the following code

##Copy code

The code is as follows:

<tagLib name="html" /> 
<html:select name="uid" options="users" first="请选择用户" change="alert(‘Hello&#39;)"/>
In this way, we only use a simple tag to achieve the following functions: (Compiled HTML code)


##Copy code

The code is as follows:

<select id="" name="uid" onchange="alert(‘Hello&#39;)" ondblclick="" class=""> 
<option value="">请选择用户</option> 
<option value="1″>no1</option> 
<option value="2″>no2</option> 
<option value="3″>no3</option> 
<option value="4″>no4</option> 
</select>
Related recommendations:

ThinkPHP template judgment output Empty tag usage


Use thinkphp’s own method to generate static html files

The above is the detailed content of How to use thinkPHP's Html template tags. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn