我正在开发一个海狸生成器扩展,并且每件事情都运行良好,但问题是我想为客户提供一些可选择的选项,以便他/她可以选择他们各自的选项,我们可以提供他们的功能选择。
例如,我想提供2个选项。选项一,选择你的帖子类型?选项是" post"," custom post" ......现在,如果他/她选择"发布"我想显示一些相关的选项,但是如果他/她选择"自定义帖子"我想显示与自定义帖子相关的选项。我在视觉作曲家做过这件事但到目前为止还无法在海狸建造者那里做过。
以下是我的一些代码:
'sections' => array( // Tab Sections
'general' => array( // Section
'title' => __('Section Title', 'fl-builder'), // Section Title
'fields' => array( // Section Fields
'select_field' => array(
'type' => 'select',
'label' => __('Show Filter or Not?', 'fl-builder'),
'default' => 'option-1',
'options' => array(
'option-1' => __('Yes', 'fl-builder'),
'option-2' => __('No', 'fl-builder')
)
),
'no_of_posts' => array(
'type' => 'my-custom-field',
'label' => __('Provide your desired number of Posts', 'fl-builder'),
'default' => '8'
),
'no_of_cols' => array(
'type' => 'select',
'label' => __('Provide your desired number of Cols', 'fl-builder'),
'default' => 'option-2',
'options' => array(
'option-1' => __('2', 'fl-builder'),
'option-2' => __('3', 'fl-builder'),
'option-3' => __('4', 'fl-builder'),
'option-4' => __('6', 'fl-builder')
)
),
'show_overlay' => array(
'type' => 'select',
'label' => __('Do You Want to Show Overlay?', 'fl-builder'),
'default' => 'option-1',
'options' => array(
'option-1' => __('Yes', 'fl-builder'),
'option-2' => __('No', 'fl-builder')
)
),
'show_lightbox' => array(
'type' => 'select',
'label' => __('Do You Want to Open Image in lightbox?', 'fl-builder'),
'default' => 'option-1',
'options' => array(
'option-1' => __('Yes', 'fl-builder'),
'option-2' => __('No', 'fl-builder')
)
),
'show_lightbox_link' => array(
'type' => 'select',
'label' => __('Do You Want to show Link Icon in Lightbox?', 'fl-builder'),
'default' => 'option-1',
'options' => array(
'option-1' => __('Yes', 'fl-builder'),
'option-2' => __('No', 'fl-builder')
)
),
'show_title' => array(
'type' => 'select',
'label' => __('Do You Want to show Post Title?', 'fl-builder'),
'default' => 'option-1',
'options' => array(
'option-1' => __('Yes', 'fl-builder'),
'option-2' => __('No', 'fl-builder')
)
),
'show_title_link' => array(
'type' => 'select',
'label' => __('Do You Want to use Link in Post Title?', 'fl-builder'),
'default' => 'option-1',
'options' => array(
'option-1' => __('Yes', 'fl-builder'),
'option-2' => __('No', 'fl-builder')
)
),
'show_content' => array(
'type' => 'select',
'label' => __('Do You Want to show Post Content?', 'fl-builder'),
'default' => 'option-1',
'options' => array(
'option-1' => __('Yes', 'fl-builder'),
'option-2' => __('No', 'fl-builder')
)
),
'show_link' => array(
'type' => 'select',
'label' => __('Do You Want to show Post Link?', 'fl-builder'),
'default' => 'option-1',
'options' => array(
'option-1' => __('Yes', 'fl-builder'),
'option-2' => __('No', 'fl-builder')
)
),
重点很简单:我只想在选择其他相关选项时显示我的选项。
例如,如果用户选择选项" post"那应该这样做
'no_of_cols' => array(
'type' => 'select',
'label' => __('Provide your desired number of Cols', 'fl-builder'),
'default' => 'option-2',
'options' => array(
'option-1' => __('2', 'fl-builder'),
'option-2' => __('3', 'fl-builder'),
'option-3' => __('4', 'fl-builder'),
'option-4' => __('6', 'fl-builder')
)
),
意味着我只想在选择帖子等时显示选择选项。希望我能清楚地传达我的问题。
答案 0 :(得分:0)
我可能已经太迟了!
但你只需要使用'切换'。
'select_field' => array(
'type' => 'select',
'label' => __('Show Filter or Not?', 'fl-builder'),
'default' => 'option-1',
'options' => array(
'option-1' => __('Yes', 'fl-builder'),
'option-2' => __('No', 'fl-builder')
),
'toggle' => array(
'option-1' = array(
'fields' => array('another_field')
)
)
),
'another_field' => array()