找回密码
 立即注册
相关推荐换一批
  1. WordPress极致主题4.0RiPro美化版网站源码
  2. 织梦CMS精仿QQ技术导航网站源码
  3. WordPress响应式主题CorePress v2.6
  4. 小水滴2.0导航模板去授权破解版
  5. 最新卡卡云模板V1.0适配彩虹代唰系统
  6. JT/T 1236-2019 公路声屏障紧急疏散出口设置要求
  7. GA/T 851-2009 人行横道信号灯控制设置规范
  8. YD/T 1405-2005 公用电信网间电话业务路由设置的技术要求
  9. GA/T 1047-2013 道路交通信息监测记录设备设置规范
  10. YY/T 0457.7-2003/IEC 61262-7: 1995 医用电气设备光电X射线影像增强器特性 第7部分
  11. TB/T 3509.1-2018 铁路运输标识第1部分:货运
  12. YY/T 1279-2015 三维超声成像性能试验方法
  13. YY/T 0873.5-2014/ISO 6360-5 :2007 牙科旋转器械的数字编码系统 第5部分:牙根管器?
  14. YY/T 0864-2011 医用内窥镜内窥镜功能供给装置液体膨腔泵
  15. YY/T 0906-2013 B型超声诊断设备性能试验方法配接腔内探头
  16. GB/T 31384-2024旅游景区公共信息导向系统设置规范
  17. NB/T 20424-2017 核电厂限流孔板设置要求
  18. GB/T 15566.3-2020 公共信息导向系统 设置原则与要求 第3部分:铁路旅客车站
  19. DL/T 785-2001 火力发电厂中温中压管道(件)安全技术导则
  20. GA/T 1567-2019 城市道路交通隔离栏设置指南
  21. GB∕T 37915-2019 社区商业设施设置与功能要求
  22. DB11 844-2012 公路护栏设置规范
  23. 中山大学附属小学2016-2017学年度一年级英语上学期期末学业水平测试卷
  24. 2013年新派英语一年级下册期末综合测试卷(含听力材料与参考答案)
The设置数组options | 博客 2022-04-25 377 0star收藏 版权: . 保留作者信息 . 禁止商业使用 . 禁止修改作品
插件介绍
长期以来,emlog 走的是轻量级路线,不集成模板后台设置,所以很多强大的模板需要修改文件才能更改设置。那么,有了这个插件,你就不用这么纠结了。只要按照开发规范开发模板,就可以使用这个插件在后台进行设置。

如何让插件识别模板?
将options.php放到模板目录下,内容格式如下,可以任意添加设置项,注意$options变量和注释:
<?php
/*@support tpl_options*/
!defined('EMLOG_ROOT') && exit('访问权限已定义!');
$选项 = 数组(
        '侧边栏' => 数组(
                '类型' => '收音机',
                '名称' => '侧边栏位置',
                '值' => 数组(
                        '左' => '左',
                        '正确' => '正确'
                ),
                '默认' => '正确',
        ),
        'sortIcon' => 数组(
                '类型' => '图像',
                'name' => '分类图标设置',
                '值' => 数组(
                        模板网址。 '图像/star.png',
                ),
                '依赖' => '排序',
                '未排序' => 真的,
                'description' => '为不同的分类设置不同的小图标,最好是20×20',
        ),
);


在 options.php 中,每个元素应该写什么?
如上图,$options数组中,key为设置项的id,value为包含多个元素的数组。 type属性和name属性是必须的,name是设置项的名称,type用来指定设置项的类型。支持的类型如下:
单选:单选按钮
复选框:检查按钮
文字:文字
图片:图片
页:页
排序:排序
标签: 标签
对于所有类型,默认属性用于指定默认值。不指定default时,使用values中的第一个值。如果两者都没有指定,则使用一个奇怪的默认值。
对于radio和chexkbox,values属性用来设置每个按钮的值和显示名称。
除了sort,可以指定depend为sort,也就是说这个选项可以根据不同的类别设置不同的值。当指定依赖为排序时,可以选择未排序的属性。为true时,表示包含unsorted,不包含false。默认为真。
sort 和 page 可以将 multi 属性设置为 true,表示多选。
description 属性是可选的,用于描述选项。
如果type为text,multi属性可以设置为true,表示多行文本,即input和textarea的区别。可选属性rich 用于支持富文本。如果设置了此值,则将加载编辑器。
如果type是sort、page或tag,并且设置了多选,则默认值为空,否则为该类型的第一个值。

如何调用模板中的设置项
插件提供了一个简单的方法 *_g($key),如上例,可以使用 _g('sidebar') 获取侧边栏的设置,值为 0 或 1,使用 _g('sortIcon' ) 要获取类别图标的所有设置,使用 _g('sortIcon.1') 以类别 id 为键的数组获取类别 id 为 1(如果存在)的 sortIcon。需要注意的是,对于页面类型,会获取页面id,排序类型,获取类别id,标签类型,获取标签名称。如果不传递任何参数,则所有设置都将使用 _g() 方法获取。对于迁移的旧模板,可以使用 extract(_g());* 替换原来的加载选项文件。

(Plug in introductionFor a long time, emlog has taken a lightweight route and does not integrate template background settings. Therefore, many powerful templates need to modify files to change settings. Well, with this plug-in, you don't have to be so tangled. The plug-in can be developed in the background according to this specification.How to make the plug-in recognize the template?Set options PHP is placed in the template directory. The content format is as follows. You can add any setting item. Note the $options variable and comments:<? php/*@support tpl_ Options*/! Defined ('emlog_root ') & & exit ('Access rights defined!');$option = array('sidebar '= > array('type '= >' radio ','name' = > 'sidebar position','value' = > array('left' = > 'left','correct' = > 'correct'),'default '= >' correct ',),'sorticon '= > array('type '= >' image ','name' = > 'classification icon settings','value' = > array(Template URL. ' Image / star png',),'dependency '= >' sort ','not sorted' = > really,'description '= >' set different small icons for different categories, preferably 20 × 20',),);In options What should each element write in PHP?As shown in the figure above, in the $options array, key is the ID of the setting item and value is the array containing multiple elements. The type attribute and name attribute are required. Name is the name of the setting item, and type is used to specify the type of the setting item. The supported types are as follows:Radio: radio buttonCheck box: check buttonText: TextPicture: picturePage: pageSorting: sortingLabels: labelsSpecifies the default value for all attributes. When default is not specified, the first value in values is used. If neither is specified, a strange default value is used.For radio and chexkbox, the values attribute is used to set the value and display name of each button.In addition to sort, you can specify depend as sort, that is, this option can set different values according to different categories. When a dependency is specified as sort, you can select an unsorted attribute. When it is true, it means that it contains unsorted and does not contain false. The default is true.Sort and page can set the multi attribute to true, indicating multiple choices.The description attribute is optional and is used to describe the options.If the type is text, the multi attribute can be set to true, indicating the difference between input and textarea. The optional property rich is used to support rich text. If this value is set, the editor loads.If the type is sort, page or tag, and multiple selections are set, the default value is empty; otherwise, it is the first value of the type.How to call a setting item in a templateThe plug-in provides a simple method*_ G ($key), as in the above example, can be used_ G ('sidebar ') get the setting of the sidebar. The value is 0 or 1. Use_ G ('sorticon ') to get all the settings of the category icon, use_ G ('sorticon. 1 ') the array with category ID as the key gets the sorticon with category ID of 1 (if any). It should be noted that for the page type, the page ID, sorting type, category ID, tag type and tag name will be obtained. If no parameters are passed, all settings are used_ G () method. For the migrated old template, you can use extract (_g())* Replace the original load options file.)

[下载]18014152321.rar




上一篇:emlog 蓝叶精简代码高亮插件
下一篇:Emlog ThemeSwitcher多设备主题切换器插件