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
Name | Type | Default | Description. |
---|---|---|---|
icon | string | 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_type | string | Set to image when using a custom URL to an icon. | |
title | string | The title of the section that will appear on the option tab. | |
heading | string | 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. | |
desc | string | Text to appear under the section title. HTML is permitted. | |
class | string | Appends any number of classes to the section’s class attribute. | |
permissions | string | String specifying the capability required to view the section. See Using Permissions. | |
customizer_only | array | An array of arrays representing individual options. | |
subsection | bool | 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',
),
),
);