ECSHOP模版系统显示标签使用介绍 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

    这篇文章主要介绍了ECSHOP模版系统显示标签使用介绍,需要的朋友可以参考下

    ECSHOP模版系统中显示标签主要是转换HTML代码,该特性使得在表格中交替输出颜色或轮转使用数组中的值变得很容易,或者是根据给定的数据创建选项组,创建日期下拉菜单,它可以显示任意年月日,

ECSHOP模版系统显示标签使用介绍

。亦或者是根据给定的数据创建单选按钮组等,本文就给大家讲解一下ECSHOP模版系统的显示标签。

cycle

属性类型是否必须缺省值描述namestringNodefault轮转的名称valuesmixedN/A待轮转的值,可以是用逗号分隔的列表(请查看 delimiter 属性)或一个包含多值的数组.printbooleanNotrue是否输出值advancebooleanNotrue是否使用下一个值(为 false 时使用当前值)delimiterstringNo,指出values 属性中使用的分隔符,默认是逗号.assignstringNoN/A输出值将被赋给模板变量的名称

    描述:

    Cycle 用于轮转使用一组值. 该特性使得在表格中交替输出颜色或轮转使用数组中的值变得很容易。

    如果需要在模板中使用多个轮转,需要给出唯一的 name 属性.

    用户可以设置 print 属性为 false 强制不输出当前值. 该特性可以很方便地略过某个值.

    advance 属性用于重复使用某个值. 当该属性设置为 false 时,下次调用该轮转时将输出同样的值.

    如果指定了 “assign” 这个特殊属性,该轮转的输出值将被赋给由 assign 指定的模板变量,而不是直接输出。

    例子:

{section name=rows loop=$data}<tr bgcolor="{cycle values="#eeeeee,#d0d0d0"}"><td>{$data[rows]}</td></tr>{/section}

    输出:

<tr bgcolor="#eeeeee"><td>1</td></tr><tr bgcolor="#d0d0d0"><td>2</td></tr><tr bgcolor="#eeeeee"><td>3</td></tr>

html_options

属性类型是否必须缺省值描述valuesarrayYes, unless using options attributeN/A包含下拉列表各元素值的数组outputarrayYes, unless using options attributeN/A包含下拉列表各元素显示值的数组selectedstring/arrayNoempty已选定的元素或元素数组optionsassociative arrayYes, unless using values and outputN/A包含值和显示的关联数组namestringNoempty下拉菜单的名称

    描述:

    自定义函数 html_options 根据给定的数据创建选项组. 该函数可以指定哪些元素被选定. 要么必须指定 values 和 ouput 属性,要么指定 options 替代。

    如果给定值是数组,将作为 OPTGROUP 处理,且支持递归. 所有的输出与 XHTML 兼容。

    如果指定了可选属性 name,该选项列表将将被置于标签对中. 如果没有指定,那么只产生选项列表。

    上表未提到的其它参数在 标签中以”名称/属性”对的方式显示.

    例子:

    index.php:

require(‘Smarty.class.php‘);$smarty = new Smarty;$smarty->assign(‘cust_ids‘, array(1000,1001,1002,1003));$smarty->assign(‘cust_names‘, array(‘Joe Schmoe‘,‘Jack Smith‘,‘JaneJohnson‘,‘Carlie Brown‘));$smarty->assign(‘customer_id‘, 1001);$smarty->display(‘index.tpl‘);index.tpl:{html_radios values=$cust_ids checked=$customer_id utput=$cust_namesseparator="<br />"}

    index.php:

require(‘Smarty.class.php‘);$smarty = new Smarty;$smarty->assign(‘cust_radios‘, array(1001 => ‘Joe Schmoe‘,1002 => ‘Jack Smith‘,1003 => ‘Jane Johnson‘,1004 => ‘Charlie Brown‘));$smarty->assign(‘customer_id‘, 1001);$smarty->display(‘index.tpl‘);

    index.tpl:

{html_radios name="id" ptions=$cust_radios checked=$customer_id separator="<br />"}

    输出:

<input type="radio" name="id[]" value="1000">Joe Schmoe<br /><input type="radio" name="id[]" value="1001" checked="checked"><br /><input type="radio" name="id[]" value="1002">Jane Johnson<br /><input type="radio" name="id[]" value="1003">Charlie Brown<br />

最新文章