部件入门

Getting Started with Sections

部件入门

Before any Field array is written, which will represent(代表) the individual options(个人选项) on the options panel, a section must be created. The section array sets up a tab on the side of the Redux options panel, where the Field arrays will ultimately go.

选项面板中代表个人选项的字段在书写之前,一个部件必须被创建。这个部件在选项面板一边设置一个TAB

The setSections function 设置部件函数

Section arrays are declared in the setSections function of your config file, or by default, sample-config.php. To see for yourself, open the sample-config.php file in your favorite PHP editor and scroll down to the setSections function. In addition to section arrays, and code your section might depend on should also be placed here. As seen in the sample-config file, there is a section of code toward the top which enumerates image files in the sample/patterns directory for use in image_select field example.

To set up a new section, we need to pass the entire section code into the public sections array of the Redux_Framework_sample_config class. To begin, use the code below:

数组中的第setsections功能符合你的配置文件,或在默认情况下,sample-config.php。看到的是你自己开的,你最喜欢的sample-config.php文件在PHP和setsections向下滚动到编辑器的功能。此外,部分阵列和代码,你应该也可能取决于部分被放置在这里。看到的配置文件中的示例代码,有一个从顶部截面图像文件中的enumerates指南中使用的样本图像/模式选择_场的例子。


要设置新的部分,我们需要通过整个截面的公共代码段阵列的样品_ _归来_框架配置类。开始,使用下面的代码:

$this->sections[] = array(
    'title' => 'New Section',
);

Set the title argument to whatever you would like to name the section. Whatever title you choose will be the title that appears on the actual section tab of the options framework. Use the arguments listed below to further set the section arguments.

Arguments

NameTypeDefaultDescription.
iconstring The icon to be displayed next to the section title. This could be a preset Elusive Icon or a URL to an icon of your own.
icon_typestring Set to image when using a custom URL to an icon.
titlestring The title of the section that will appear on the option tab.
headingstring Text to appear at the top of the section page. By default the title argument is used as the title. Text specified via this argument replaces it.
descstring Text to appear under the section title. HTML is permitted.
classstring Appends any number of classes to the section’s class attribute.
permissionsstring String specifying the capability required to view the section.  See Using Permissions.
customizer_onlyarray An array of arrays representing individual options.
subsectionbool Boolean to denote if this section should appear as a subsection to the previously defined section.

Here is an example of a typical sections array with a single text box option

:

$this->sections[] = array(
    'title'   => 'New Section',
    'icon'    => 'el-icon-cogs',
    'heading' => 'Expanded New Section Title',
    'desc'    => '<br />This is the section description.  HTML is permitted.<br />'
    'fields'  => array(
        array(
            'id'    => 'opt-text',
            'type'  => 'text',
            'title' => 'A sample text box',
        ),
    ),
);

Related Articles


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值