首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在创建模块设置的同一文件中获取海狸生成器自定义模块设置数据?

如何在创建模块设置的同一文件中获取海狸生成器自定义模块设置数据?
EN

Stack Overflow用户
提问于 2016-10-19 12:46:24
回答 1查看 924关注 0票数 2

在beaver builder自定义模块开发中,如何获得创建设置的结果与我创建这些设置的页面相同。例如,如果我在custom.php文件中创建设置,而这些设置在frontend.php文件中可用,而我希望在custom.php文件中获得这些保存的值.有可能吗?如果这是可能的话,怎么做呢?

以下是我在custom.php文件中的数据:

代码语言:javascript
复制
FLBuilder::register_module('FLExampleModuleGallery', array(
'general'       => array( // Tab
    'title'         => __('General', 'fl-builder'), // Tab title
    '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')
                    )
                ),
            )
        )
    )
),

  ));

下面是frontend.php中获取这些值的代码:

代码语言:javascript
复制
$show_lightbox = $settings->show_lightbox;
$show_lightbox_link = $settings->show_lightbox_link;
$show_title = $settings->show_title;
$show_title_link = $settings->show_title_link;
$show_content = $settings->show_content;
$show_link = $settings->show_link;

如何在custom.php文件中获得上述值?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-29 10:52:39

在您自己的模块类中创建一个自定义方法,如下所示:

代码语言:javascript
复制
public function  custom_file(){
  $settings = $this->settings;
  require_once 'includes/custom.php';
}

现在调用enqueue_scripts()方法,如下所示:

代码语言:javascript
复制
public function enqueue_scripts(){
  $this->custom_file();
}

或者在你的frontend.php中:

代码语言:javascript
复制
$module->custom_file();

最后创建custom.php,然后检查$settings值,看看它是否有效

代码语言:javascript
复制
var_dump($settings);

希望这能被现代发展标准所接受。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40131794

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档