smarty函数
内置函数(重要的几个):
<{html_checkboxes name='nation' values=$code output=$name selected=$selid separator='<br />'}>//复选框
<{html_options name='ceshi' options=$xuanxiang selected=$selids}>//下拉列表
<{html_select_date start_year="1990" end_year="2020" month_format="%m" field_order="YMD" field_array="aa"}>//日期
<{html_select_time use_24_hours=true}>//时间
自定义函数:
1、<{jiandan cishu=10 neirong='hello'}>//函数调用
function.jiandan.php //文件
<?php
function smarty_function_jiandan($args)//$args是一个数组,不是可变函数,参数以数组形式传入
{
//1.循环次数 cishu
//2.循环内容 neirong
//array('cishu'=>10,'neirong'=>'hello')
$num = $args["cishu"];
$neirong = $args["neirong"];
$str = "";
for($i=0;$i<$num;$i++)
{
$str = $str.$neirong;
}
return $str;
}
2、块函数--》写法,调用两次,标识
<{biaoji size=24}> //size是参数
hello world //$content
<{/biaoji}>
block.biaoji.php //文件
<?php
function smarty_block_biaoji($args,$content,$smarty,$bs)
{
//return "aa---{$content}--{$bs}<br>"; 输出页面上试试,标识-->是否是第一次调用
if(!$bs)
{
$size = $args["size"];
$content = "<mark style='font-size:{$size}px'>{$content}</mark>";
return $content;
} }
3、自带控件:
<{textarea name='editer' toolbar='full' height=300 color=red}><{/textarea}>
block.textarea.php
<{color name='color' value='#000000'}>
function.color.php
<{date name='riqi' value='2016-7-24' time=1}>
function.date.php
//自己建相应的文件
smarty函数的更多相关文章
- Smarty 函数
html_checkboxes 自定义函数 html_checkboxes 根据给定的数据创建复选按钮组. 该函数可以指定哪些元素被选定. 要么必须指定 values 和 ouput 属性,要么指定 ...
- smarty模板配置代码详细说明及如何注册自己的smarty函数
下面为smarty模板的配置文件,smarty配置的详细说明以及如何注册自己所需要的smarty函数 config.inc.php <?php /** * Smarty 调用 * www.daf ...
- smarty函数-转载
Smarty常用函数 2009-08-13 14:05:55| 分类: Php |举报 |字号 订阅 1 .include_once语句: 引用文件路径,路径必需正确. eg:include ...
- smarty函数-继承extents
继承<{extends}> {extends}标签用在模版中的第一行: 如果子模板用{extends}标签继承父模板,那么它只能包含{block}标签(内容),其它任何模板内容都将忽略: ...
- smarty使用
smarty-牛刀小试 smarty 初识 官网 http://www.smarty.net/ Smarty is a template engine for PHP(PHP模板引擎) smarty使 ...
- 12月15日smarty模板基本语法
smarty基本语法: 1.注释:<{* this is a comment *}>,注意左右分隔符的写法,要和自己定义的一致. <{* I am a Smarty comment, ...
- smarty基本语法
smarty基本语法: 1.注释:<{* this is a comment *}>,注意左右分隔符的写法,要和自己定义的一致. <{* I am a Smarty comment, ...
- Smarty模板学习
1.基本语法 所有的smarty模板标签都被加上了定界符.默认情况下是 { 和},但它们是可被改变的. 在smarty里,所有定界符以外的内容都是静态输出的,或者称之为不可改变.当smarty遇到了模 ...
- Smarty属性
Attributes [属性] 大多数函数都带有自己的属性以便于明确说明或者修改他们的行为. smarty函数的属性很像HTML中的属性. 静态数值不需要加引号,但是字符串建议使用引号. 如果用 ...
随机推荐
- 2016年11月3日JS脚本简介数据类型: 1.整型:int 2.小数类型: float(单精度) double(双精度) decimal () 3.字符类型: chr 4.字符串类型:sting 5.日期时间:datetime 6.布尔型数据:bool 7.对象类型:object 8.二进制:binary 语言类型: 1.强类型语言:c++ c c# java 2.弱类型语
数据类型: 1.整型:int 2.小数类型: float(单精度) double(双精度) decimal () 3.字符类型: chr 4.字符串类型:sting 5.日期时间:datetime 6 ...
- javascript js表示中文日期的经典写法
<div id="time"> <script>document.getElementById('time').innerHTML=new Date().t ...
- pstack使用和原理
前言: 最近小组在组织<<深入剖析Nginx>>的读书会, 里面作者提到了pstack这个工具. 之前写JAVA程序, 对jstack这个工具, 非常的喜欢, 觉得很有用. 于 ...
- 《C标准库》——之<stddef.h>
<stddef.h>,顾名思义,就是标准定义.C语言里这个标准库里定义了一些类型,和宏定义. <stddef.h>的内容: 类型: ptrdiff_t : 是两个指针相减的结果 ...
- ubuntu14.04 and ros indigo install kinect driver--16
摘要: 原创博客:转载请表明出处:http://www.cnblogs.com/zxouxuewei/ 今日多次测设ros indigo install kinect driver ,提示各种失败,然 ...
- leetcode 38 Count and Say ---java
这道题主要就是求一个序列,题目得意思就是 1 --> 11 --> 21 --> 1211 --> 111221 --> 312211 --> ..... 1个 ...
- mysql之数据库连接的方法封装及防sql注入
一.定义数据库和表 create database animal; CREATE TABLE `pet` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name ...
- 某种数列问题 (jx.cpp/c/pas) 1000MS 256MB
众所周知,chenzeyu97有无数的妹子(阿掉!>_<),而且他还有很多恶趣味的问题,继上次纠结于一排妹子的排法以后,今天他有非(chi)常(bao)认(cheng)真(zhe)去研究一 ...
- hihoCoder#1055 : 刷油漆 (树形DP+01背包)
题目大意:给一棵带点权的树,现在要从根节点开始选出m个连通的节点,使总权值最大. 题目分析:定义状态dp(u,m)表示在以u为根的子树从根节点开始选出m个点连通的最大总权值,则dp(u,m)=max( ...
- [luogu P2170] 选学霸(并查集+dp)
题目传送门:https://www.luogu.org/problem/show?pid=2170 题目描述 老师想从N名学生中选M人当学霸,但有K对人实力相当,如果实力相当的人中,一部分被选上,另一 ...