【问题标题】:Visual Composer Nested shortcodes in a container容器中的 Visual Composer 嵌套简码
【发布时间】:2018-08-08 14:02:46
【问题描述】:

我刚刚使用 vc_map 为 wordpress 网站创建了一个嵌套短代码。

效果很好,而且非常简单。

我的父简码是“simple_table”,我的孩子简码是“simple_table_row”。

[simple_table param="foo"]
   [simple_tablerow param="another_foo"]
   [simple_tablerow param="another_foo"]
   [simple_tablerow param="another_foo"]
[/simple_table]

我可以在页面的根目录或行中添加我的简码。

但是,我无法在另一个容器中添加,例如标签、游览、手风琴或 Pageable Container。我的嵌套短代码未出现在元素列表中。我已经创建了几个在这些特定情况下正常工作的简单短代码。

这是我的 vc_map :

vc_map( array(
    "name" => "Simple_table",
    "description" => "Simple_table",
    "base" => "simple_table",
    "class" => "simple_table",
    "content_element" => true,
    "is_container" => true,
    'as_parent' => array('only' => 'simple_tablerow'),
    "show_settings_on_create" => true,
    "icon" => "simple_table_icon", 
    "category" => __('Content', 'js_composer'),
    "js_view" => 'VcColumnView',
    "params" => array(
                    array(
                        'type' => 'param_group',
                        'value' => '',
                        'param_name' => 'cols',
                        "heading" => "Cols",
                        'params' => array(
                            array(
                                'type' => 'textfield',
                                "holder" => "div",
                                'value' => '',
                                'heading' => 'Data',
                                'param_name' => 'data',
                                'admin_label' => true,
                            ),
                            array(
                                'type' => 'textfield',
                                'value' => '',
                                'heading' => 'Style',
                                'param_name' => 'style',
                            ),
                            array(
                                'type' => 'textfield',
                                'value' => '',
                                'heading' => 'Class',
                                'param_name' => 'class',
                            )
                        )
                    ),
                    array(
                      "type" => "checkbox",
                      "class" => "",
                      "heading" => "hide_header",
                      "param_name" => "hide_header"
                  ),
                    array(
                         "type" => "textfield",
                         "holder" => "",
                         "class" => "",
                         "heading" => "Class",
                         "param_name" => "class"
                    ),
      ),
    )
);

vc_map( array(
    "name" => "Simple_tablerow",
    "description" => "simple_tablerow",
    "base" => "simple_tablerow",
    "class" => "simple_tablerow",
    "content_element" => true,
    "as_child" =>  array('only' => 'simple_table'),
    "show_settings_on_create" => true,
    "icon" => "hide_header",
    "category" => __('Content', 'js_composer'),
    "params" => array(
        array(
            'type' => 'param_group',
            'value' => '',
            'param_name' => 'cols',
            "heading" => "Cols",
            'params' => array(
                array(
                    'type' => 'textfield',
                    'value' => '',
                    'heading' => 'Data',
                    'param_name' => 'data',
                    'admin_label' => true,
                ),
                array(
                    'type' => 'textfield',
                    'value' => '',
                    'heading' => 'Style',
                    'param_name' => 'style',
                ),
                array(
                    'type' => 'textfield',
                    'value' => '',
                    'heading' => 'Class',
                    'param_name' => 'class',
                )
            ),
        ),
        array(
            'type' => 'textfield',
            'value' => '',
            'heading' => 'Class',
            'param_name' => 'class',
        )
    ),
    )
);

如何在标签、游览、手风琴或 Pageable Container 等容器中添加可用的嵌套短代码?

注意:参数“allowed_container_element”似乎是原因,但我该如何修改这个值?

【问题讨论】:

    标签: wordpress visual-composer


    【解决方案1】:

    希望你已经找到了这个问题的答案,因为这有点旧,但我自己正在寻找答案,结果出现了。

    此文档站点可能对您有用https://kb.wpbakery.com/docs/developers-how-tos/nested-shortcodes-container/

    如果我不得不猜测,您似乎忘记了扩展 WPBakeryShortCodesContainer 底部的最后一段代码

    //Your "container" content element should extend WPBakeryShortCodesContainer class to inherit all required functionality
    if ( class_exists( 'WPBakeryShortCodesContainer' ) ) {
      class WPBakeryShortCode_Your_Gallery extends WPBakeryShortCodesContainer {
      }
    }
    if ( class_exists( 'WPBakeryShortCode' ) ) {
      class WPBakeryShortCode_Single_Img extends WPBakeryShortCode {
      }
    }
    

    【讨论】:

      【解决方案2】:

      从最初的问题到现在已经 3 年多了,但我遇到了类似的问题。删除以下行对我有用:

      "is_container" => true,
      

      【讨论】:

        猜你喜欢
        • 2018-01-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多