簡體   English   中英

Visual Composer將短代碼嵌套在容器中

[英]Visual Composer Nested shortcodes in a container

我剛剛為WordPress網站使用vc_map創建了一個嵌套的簡碼。

它運行良好,非常簡單。

我的父母的簡碼是“ 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容器。 我嵌套的簡碼未出現在元素列表中。 我已經創建了一些簡單的簡碼,在這些特定情況下可以正常工作。

這是我的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容器等容器中添加可用的嵌套短代碼?

注意:參數“ allowed_container_element”似乎是原因,但是如何修改該值?

希望您已經找到了答案,因為它有點舊了,但是我自己正在尋找答案,所以就提出了。

您可能會使用此文檔站點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 {
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM