wpbakery get parent container element's paremeter value inside child contentainer in visual composer - wordpress

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.

Related

Meta box tabs - in a custom post type

Is it possible to insert meta box tabs in a specific custom post type.
I've been looking at the example :
add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
// 1st Meta Box
$meta_boxes[] = array(
'title' => 'Meta Box Tabs Demo',
// List of tabs, in one of the following formats:
// 1) key => label
// 2) key => array( 'label' => Tab label, 'icon' => Tab icon )
'tabs' => array(
'contact' => array(
'label' => 'Contact',
'icon' => 'dashicons-email', // Dashicon
),
'social' => array(
'label' => 'Social Media',
'icon' => 'dashicons-share', // Dashicon
),
'note' => array(
'label' => 'Note',
'icon' => 'https://i.imgur.com/nJtag1q.png', // Custom icon, using image
),
),
// Tab style: 'default', 'box' or 'left'. Optional
'tab_style' => 'default',
// Show meta box wrapper around tabs? true (default) or false. Optional
'tab_wrapper' => true,
'fields' => array(
array(
'name' => 'Name',
'id' => 'name',
'type' => 'text',
// Which tab this field belongs to? Put tab key here
'tab' => 'contact',
),
array(
'name' => 'Email',
'id' => 'email',
'type' => 'email',
'tab' => 'contact',
),
array(
'name' => 'Facebook',
'id' => 'facebook',
'type' => 'text',
'tab' => 'social',
),
array(
'name' => 'Note',
'id' => 'note',
'type' => 'textarea',
'tab' => 'note',
),
),
);
This will work in post if added to functions.php ... but if we try to use it in a custom post type the metabox will appear but the fields will not.
Any help would be appreciated.

Visual Composer Nested shortcodes in a container

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,

Contao Wrap Leff and Right Class TL_DCA Fields

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'),
),

Visual Composer custom markup for custom shortcode (vc_map)

Trying to get custom_markup to work with the Visual Composer builder for WordPress.
Found Visual Composer change custom shortcode template and also Visual Composer custom shortcode template - custom_markup display user input but none of them has an answer.
Here's some documentation for the vc_map function https://wpbakery.atlassian.net/wiki/pages/viewpage.action?pageId=524332
Here's my shortcode that I'm using, everything works perfectly, it just looks horrible in the backend ui
vc_map( array(
"name" => "example",
"base" => "adwise_vc_example",
"class" => "",
"category" => "Plugin name",
"icon" => "awm_vc_icon",
"custom_markup" => load_template( ADWISE_VC_DIR . '/vc_templates/adwise_example.php', false),
"params" => array();
Which currently looks like --> https://dl.dropboxusercontent.com/u/11204765/SS/mac/Screen%20Shot%202016-05-02%20at%2012.52.56.png
In the example below I've tried to set custom_markup to test
which results in https://dl.dropboxusercontent.com/u/11204765/SS/mac/Screen%20Shot%202016-05-02%20at%2012.45.55.png
vc_map( array(
"name" => "example",
"base" => "adwise_vc_example",
"class" => "",
"category" => "Plugin name",
"icon" => "awm_vc_icon",
"custom_markup" => "test",
"params" => array();
My primary/main problem is that I don't know how to get the values of each attribute for each shortcode to display in the template file.
I've looked almost everywhere for a solution, including browsing through other Visual Composer plugins to see how they've accomplished this.
Any help would be greatly appreciated!
What are you trying to accomplish exactly ? From the visual composer core code this is the custom markup for the tabs
'custom_markup' => '
<div class="wpb_tabs_holder wpb_holder vc_container_for_children">
<ul class="tabs_controls">
</ul>
%content%
</div>',
So maybe something like %customattr% will get your desired result?
just add an array with the shortcode attributes in 'params'
'params' => array(
array(
'type' => 'textfield',
'holder' => 'div',
'class' => '',
'heading' => __( 'Title' ),
'param_name' => 'title',
'value' => __( 'Titre' ),
'description' => __( 'Title' ),
),
array(
'type' => 'textarea',
'holder' => 'div',
'class' => '',
'heading' => __( 'Description' ),
'param_name' => 'desc',
'value' => __( 'description' ),
'description' => __( 'Description' ),
),
array(
'type' => 'attach_image',
'holder' => 'img',
'class' => '',
'heading' => __( 'Image' ),
'param_name' => 'img_url',
'value' => __( '' ),
'description' => __( 'Image' ),
),
)
and if you want hide a section in the backend just remove the 'holder' line

wordpress - What are the valid values of 'std' for 'List Item' option tree type?

I want to have a default value ('std') for a list-item type. I know how to set std for types other than list-item. Here's an example:
array(
'id' => 'logo',
'label' => 'Logo',
'std' => OT_URL.'others/logo#2x.png', // This is std for upload type.
'type' => 'upload',
),
array(
'id' => 'regions-page',
'label' => 'Default Page Widgets Area',
'std' => 'right', // This is std for radio-image type.
'type' => 'radio',
'choices' => array(
array(
'value' => 'right',
'label' => 'Region 2',
),
array(
'value' => 'left',
'label' => 'Region 3',
),
)
For types like radio and select there are some choices which std may refer to one of their values. list-item type has something like choices called settings. Here's an example of list-item type:
array(
'id' => 'home-ads-items',
'label' => 'Add ADS. banner under Featured Products',
'std' => '', // I want to set this in order to Image setting would be its default.
'type' => 'list-item',
'settings' => array(
array(
'id' => 'img',
'label' => 'Image',
'std' => '',
'type' => 'upload',
'class' => '',
'choices' => array()
),
...
I want to set std in order to have Image as default value. But I don't know how.
It turns out to be fairly simple actually. I'm assuming you have the latest version (2.2.0), I don't know if it works in lower versions.
So, consider this configuration:
'id' => 'colors',
'section' => 'colors',
'label' => 'Colors',
'type' => 'list-item',
'settings' => array(
array(
'id' => 'color',
'label' => 'Color',
'type' => 'colorpicker',
),
),
Now, we want to have two default colors, white and black. Simply add two arrays in the std option, and use id's as keys. So, we add:
'std' => array(
array('title' => 'White', 'color' => '#ffffff'),
array('title' => 'Black', 'color' => '#000000'),
),
That's it. You'll have two predefined colors. As you can see, we don't have a configured list-item item with id title, but it's still present, because that's a default entry available to each option.

Resources