I just created a nested shortcode with vc_map for a wordpress website.
It works pretty well and is really simple.
My parent shortcode is "simple_table" and my chlidren shortcode are "simple_table_row".
[simple_table param="foo"]
[simple_tablerow param="another_foo"]
[simple_tablerow param="another_foo"]
[simple_tablerow param="another_foo"]
[/simple_table]
I can add my shortcode in the root of a page or in row.
However I am unable to add inside an another container like tabs, tour, accordion or Pageable Container. My nested shortcode doesn't appear in the list of elements. I already created several simples shortcodes which work properly in these specific cases.
Here are my 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',
)
),
)
);
How can I add my nested shortcodes available in container like tabs, tour, accordion or Pageable Container ?
Note : The parameter "allowed_container_element" seems to be the cause, but how do I modify this value ?
Hopefully you found the answer to this already, since this is a bit old, but I was searching for an answer myself and this came up.
This documentation site might be of use to you https://kb.wpbakery.com/docs/developers-how-tos/nested-shortcodes-container/
If I had to guess, it seems you forgot the last bit of code at the bottom where you extend the 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 {
}
}
It's been over 3 years from original question, but i had similar problem. Removing the following line worked for me:
"is_container" => true,
Related
Am trying to get the ID of single product page inside my function but it's returning bool(false) or NULL.
What am trying to achieve is to get the ID to filter the categories taxonomies terms of a specific product and display it in a tab using ACF but unfortunately am not able to get the ID.
I have the global $post code working in the meta box I added for the single products edit page so I'm not sure what am missing here.
Below is my code:
function my_acf_add_local_field_groups() {
global $post;
var_dump($post); // returns NULL and bool(false) when echo'd
acf_add_local_field_group(array(
'key' => 'tab_group_1',
'title' => 'Product Sizes and Prices',
'name' => 'group_sizes_tab',
'fields' => array (
array (
'key' => 'field_tab_size_1',
'label' => 'First Size',
'name' => 'store_sizes_',
'type' => 'tab',
'parent' => 'tab_group_1',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'collapsed' => '',
'min' => '',
'max' => '',
),
array (
'key' => 'field_unique_key',
'label' => 'Simple Repeater',
'name' => 'simple_repeater',
'type' => 'repeater',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'collapsed' => '',
'min' => 0,
'max' => 10,
'layout' => 'table',
'button_label' => 'Add row',
'sub_fields' => array (
array (
'key' => 'field_unique_key_1',
'label' => 'Total Products',
'name' => 'total_products',
'type' => 'text',
),
array (
'key' => 'field_unique_key_2',
'label' => 'Total Prices',
'name' => 'total_prices',
'type' => 'text',
),
),
),
array (
'key' => 'field_tab_size_2',
'label' => 'Second Size',
'name' => 'store_sizes_2',
'type' => 'tab',
'parent' => 'tab_group_1',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'collapsed' => '',
'min' => '',
'max' => '',
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'products',
),
),
),
));
}
add_action('acf/init', 'my_acf_add_local_field_groups');
I want to programmatically add a tab with repeater inside but I can't seem to find a solution, I've googled all available resources but still not working.
I already tried using acf_add_local_field_group and acf_add_local_field but still no luck.
Well I can create a tab using acf_add_local_field but when I tried to add a child which in this case a repeater OR even a text field it still doesn't work.
Here's my code to create a tab and its child but the child doesn't work.
acf_add_local_field(array(
'key' => 'field_1',
'label' => 'Sub Title',
'name' => 'sub_title',
'type' => '',
'parent' => 'field_5bd14c9349930',
'fields' => array (
array(
'key' => 'field_2',
'label' => 'This is a test',
'name' => 'my_test',
'type' => 'text',
)
)
));
You should use acf_add_local_field_group to construct the whole field group.
Here's the proper code for adding a group and a custom tab with single repeater field inside:
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array (
'key' => 'group_1',
'title' => 'My Group',
'fields' => array (
array (
'key' => 'field_unique_key',
'label' => 'First Tab',
'name' => '',
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'placement' => 'top',
'endpoint' => 0,
),
array (
'key' => 'field_unique_key',
'label' => 'Simple Repeater',
'name' => 'simple_repeater',
'type' => 'repeater',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'collapsed' => '',
'min' => 0,
'max' => 10,
'layout' => 'table',
'button_label' => 'Add row',
'sub_fields' => array ( // Here you can add as many subfields for this repeater as you want
array (
'key' => 'field_unique_key',
'label' => 'Link',
'name' => 'link',
'type' => 'link', // example link type
'instructions' => 'Link name and URL',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'return_format' => 'array',
),
),
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'post',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
));
endif;
I am using TL_DCA Feature in Contao and i want to wrap the fields inside left and right container.
$GLOBALS['TL_DCA']['table_name'] = array
(
// Config
'config' => array
(
'dataContainer' => 'Table',
),
// List
'list' => array
(),
// Fields
'fields' => array
(
'field1' => array
(
'label' => array('Suchname', 'Suchname'),
'exclude' => true,
'inputType' => 'text'
),
'field2' => array
(
'label' => array('Firma', 'Firma'),
'exclude' => true,
'inputType' => 'text'
),
'field3' => array
(
'label' => array('Name', 'Name'),
'exclude' => true,
'inputType' => 'text',
'eval' => array('mandatory' => true)
),
'field4' => array
(
'label' => array('Vorname', 'Vorname'),
'exclude' => true,
'inputType' => 'text'
),
)
)
Wrap Field and Filed 2 inside left class and Field 3 and Field 4 inside right class. So please help here.
Thanks in advance..!!!
It's possible to specific css classes for the fields:
'eval' => array('tl_class'=>'w50'),
w50 stands for width = 50%
for example:
'field1' => array
(
'label' => array('Suchname', 'Suchname'),
'exclude' => true,
'inputType' => 'text',
'eval' => array('tl_class'=>'w50'),
),
'field2' => array
(
'label' => array('Firma', 'Firma'),
'exclude' => true,
'inputType' => 'text'
'eval' => array('tl_class'=>'w50'),
),
I have created some Visual Composer Elements with parent and child attributes using "as_parent" and "as_child" parameters.
I have added some fields in parent container and some fields in the child container. What I need is to populate a child element's parameter value according to the value in the parent element field.
Is there any method I could follow to accomplish it.
Here is some of the portion of my code
vc_map( array(
"name" => __("Image Gallery", "textdomain"),
"base" => "test_image_gallery",
"as_parent" => array('only' => 'test_gal_single_element, test_gal_cat_element'),
"content_element" => true,
"show_settings_on_create" => false,
"is_container" => true,
"params" => array(
array(
"type" => "textfield",
"heading" => __("Add Filters", "textdomain"),
"description" => __( "Enter filters separated by commas. eg: filter1, filter2 etc", "textdomain" ),
"param_name" => "add_custom_filters",
'dependency' => array(
'element' => 'show_filter',
'value' => 'true',
),
),
),
"js_view" => 'VcColumnView'
) );
vc_map( array(
"name" => __("Idea", "textdomain"),
"base" => "test_gal_single_element",
"content_element" => true,
"as_child" => array('only' => 'test_image_gallery'),
"params" => array(
array(
"type" => "checkbox",
"heading" => __("Assign Filter", "textdomain"),
"param_name" => "assign_filter",
"value" => array(
'Wool' => 'Wool',
'Synthetic' => 'Synthetic',
),
),
)
)
) );
So what I need is to have the values entered in the parent param "add_custom_filters" for populating the "assign_filter" inside the child container.
Thanks.
So, I have serialized data within the uc_orders table. This data has several parameters of interest each of which I want to create a unique field from.
Each one of these $data values work on their own. Obviously I am rewriting the value on the second declaration. How can I reference the same data location twice so that both of the fields can be used and I can explode all of my serialized data into separate fields?
function uc_order_views_data() {
$data['uc_orders']['data'] = array(
'group' => t('Order') . ':data',
'title' => t('Arrival Date'),
'help' => t('Arrival date choosen by customer during checkout.'),
'field' => array(
'handler' =>'uc_order_handler_field_arrive_date',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
);
$data['uc_orders']['data'] = array(
'group' => t('Order') . ':data',
'title' => t('Ship Date'),
'help' => t('The date to ship the order by.'),
'field' => array(
'handler' =>'uc_order_handler_field_ship_date',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
);
}
I finally found the answer.
$data['uc_orders']['data2'] = array(
'group' => t('Order') . ':data',
'title' => t('Arrival Date'),
'real field' => 'data',
'help' => t('Arrival date choosen by customer during checkout.'),
'field' => array(
'handler' =>'uc_order_handler_field_arrive_date',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
);
$data['uc_orders']['data'] = array(
'group' => t('Order') . ':data',
'title' => t('Ship Date'),
'help' => t('The date to ship the order.'),
'field' => array(
'handler' =>'uc_order_handler_field_ship_date',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
);
The solution is to add 'real field' => 'field name', and change the $data id.