找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 116|回复: 0

[cms教程] ECSHOP模版系统显示标签使用介绍

[复制链接]

该用户从未签到

发表于 2019-3-24 16:29:00 | 显示全部楼层 |阅读模式

您需要 登录 才可以下载或查看,没有账号?立即注册

×
ECSHOP模版系统显示标签使用介绍
ECSHOP模版系统中显示标签主要是转换HTML代码,该特性使得在表格中交替输出颜色或轮转使用数组中的值变得很容易,或者是根据给定的数据创建选项组,创建日期下拉菜单,它可以显示任意年月日。亦或者是根据给定的数据创建单选按钮组等,本文就给大家讲解一下ECSHOP模版系统的显示标签。
cycle
   
        
            属性
            类型
            是否必须
            缺省值
            描述
        
        
            name
            string
            No
            default
            轮转的名称
        
        
            values
            mixed
            
            N/A
            待轮转的值,可以是用逗号分隔的列表(请查看 delimiter 属性)或一个包含多值的数组.
        
        
            print
            boolean
            No
            true
            是否输出值
        
        
            advance
            boolean
            No
            true
            是否使用下一个值(为 false 时使用当前值)
        
        
            delimiter
            string
            No
            ,
            指出values 属性中使用的分隔符,默认是逗号.
        
        
            assign
            string
            No
            N/A
            输出值将被赋给模板变量的名称
        
   
描述:
Cycle 用于轮转使用一组值. 该特性使得在表格中交替输出颜色或轮转使用数组中的值变得很容易。
如果需要在模板中使用多个轮转,需要给出唯一的 name 属性.
用户可以设置 print 属性为 false 强制不输出当前值. 该特性可以很方便地略过某个值.
advance 属性用于重复使用某个值. 当该属性设置为 false 时,下次调用该轮转时将输出同样的值.
如果指定了 “assign” 这个特殊属性,该轮转的输出值将被赋给由 assign 指定的模板变量,而不是直接输出。
例子:
{section name=rows loop=$data}[tr][td]{$data[rows,}[/td][/tr]{/section}
输出:
[tr][td]1[/td][/tr][tr][td]2[/td][/tr][tr][td]3[/td][/tr]
html_options
   
        
            属性
            类型
            是否必须
            缺省值
            描述
        
        
            values
            array
            Yes, unless using options attribute
            N/A
            包含下拉列表各元素值的数组
        
        
            output
            array
            Yes, unless using options attribute
            N/A
            包含下拉列表各元素显示值的数组
        
        
            selected
            string/array
            No
            empty
            已选定的元素或元素数组
        
        
            options
            associative array
            Yes, unless using values and output
            N/A
            包含值和显示的关联数组
        
        
            name
            string
            No
            empty
            下拉菜单的名称
        
   
描述:
自定义函数 html_options 根据给定的数据创建选项组. 该函数可以指定哪些元素被选定. 要么必须指定 values 和 ouput 属性,要么指定 options 替代。
如果给定值是数组,将作为 OPTGROUP 处理,且支持递归. 所有的输出与 XHTML 兼容。
如果指定了可选属性 name,该选项列表将将被置于标签对中. 如果没有指定,那么只产生选项列表。
上表未提到的其它参数在  标签中以”名称/属性”对的方式显示. 如果没有指定可选属性 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_options values=$cust_ids selected=$customer_id output=$cust_names}
index.php:
require('Smarty.class.php');$smarty = new Smarty;$smarty->assign('cust_options', 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_options options=$cust_options selected=$customer_id}
输出:
Joe SchmoeJack SmithJane JohnsonCharlie Brown
html_select_date
   
        
            属性
            类型
            是否必须
            缺省值
            描述
        
        
            prefix
            string
            No
            Date_
            变量名称前缀
        
        
            time
            timestamp/YYYY-MMDD
            No
            UNIX时间戳或年-月-日
            使用时间类型(data/time)
        
        
            start_year
            string
            No
            年份或与当前年份的相对值
            下拉列表中第一个年份,或与当前年份的相对值(正/负几年)
        
        
            end_year
            string
            No
            同start_year
            下拉列表中最后一个年份,或与当前年份的相对值(正/负几年)
        
        
            display_days
            boolean
            No
            true
            是否显示天
        
        
            display_months
            boolean
            No
            true
            是否显示月
        
        
            display_years
            boolean
            No
            true
            是否显示年
        
        
            month_format
            string
            No
            %B
            月份的表示方法(strftime)
        
        
            day_format
            string
            No
            %02d
            天显示的格式(sprintf)
        
        
            day_value_format
            string
            No
            %d
            天的表示方法(sprintf)
        
        
            year_as_text
            boolean
            No
            false
            是否以文本方式显示年份
        
        
            reverse_years
            boolean
            No
            false
            逆序显示年份
        
        
            field_array
            string
            No
            null
            如果指定了名称,选定的区域将以[Day,,[Year,,[Month,的形式返回给PHP(待考)
        
        
            day_size
            string
            No
            null
            如果给定,为标签添加大小属性
        
        
            month_size
            string
            No
            null
            如果给定,为标签添加大小属性
        
        
            year_size
            string
            No
            null
            如果给定,为标签添加大小属性
        
        
            all_extra
            string
            No
            null
            如果给定,为所有标签添加附加属性
        
        
            day_extra
            string
            No
            null
            如果给定,为标签添加附加属性
        
        
            month_extra
            string
            No
            null
            如果给定,为标签添加附加属性
        
        
            year_extra
            string
            No
            null
            如果给定,为标签添加附加属性
        
        
            field_order
            string
            No
            MDY
            显示区域的顺序
        
        
            field_separator
            string
            No
            \n
            各区域间输出的分隔字符串
        
        
            month_value_format
            string
            No
            %m
            月份值的strftime表示方法,默认为%m
        
   
描述:
自定义函数 html_select_date 用于创建日期下拉菜单. 它可以显示任意年月日.
例子:
{html_select_date}
输出:
JanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember010203040506070809101112131415161718192021222324252627282930312001
例子:
{* start and end year can be relative to current year *}{html_select_date prefix="StartDate" time=$time start_year="-5" end_year="+1"display_days=false}
输出:
JanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember1995199619971998199920002001
html_radios
   
        
            属性
            类型
            是否必须
            缺省值
            描述
        
        
            name
            string
            No
            radio
            单选按钮列表的名称
        
        
            values
            array
            Yes, 或指定 options 属性
            N/A
            包含单选按钮值的数组
        
        
            output
            array
            Yes, 或指定 options 属性
            N/A
            包含单选按钮显示值的数组
        
        
            checked
            string
            No
            empty
            已选定的元素
        
        
            options
            associative array
            Yes, 或指定 values 属性
            N/A
            包含值和显示的关联数组
        
        
            separator
            string
            No
            empty
            分隔每个单选按钮的字符串
        
   
描述:
自定义函数 html_radios 根据给定的数据创建单选按钮组. 该函数可以指定哪个元素被选定,要么必须指定 values 和 ouput 属性,要么指定 options 替代. 所有的输出与 XHTML 兼容,上表未提到的其它参数在 [i, 标签中以”名称/属性”对的方式显示.
例子:
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 output=$cust_namesseparator="
"}
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" options=$cust_radios checked=$customer_id separator="
"}
输出:
[i,Joe Schmoe
[i,
[i,Jane Johnson
[i,Charlie Brown
回复

使用道具 举报

网站地图|页面地图|文字地图|Archiver|手机版|小黑屋|找资源 |网站地图

GMT+8, 2024-10-5 17:16

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表