2017-08-09 105 views
0

不知道,我如何在Visual Composer中爲「Design Options」組添加一個新選項。在我的情況下,我需要添加容器元素的寬度。Visual Composer自定義選項

在此先感謝

回答

0

我不知道你是否能在全球所有元素設置自定義選項,但如果你正在建設一個自定義元素,你可以做這樣的事情:

vc_map(array(
     "name" => __("Custom Element Name", "my-text-domain"), 
     "base" => "custom_element", 
     "params" => array(
     array(
      'type' => 'textfield', 
      'heading' => __('Container Element Width', 'my-text-domain'), 
      'param_name' => 'container_element_width', 
      'group' => __('Design options', 'my-text-domain'), 
     ), 
    ), 
    )); 

那麼你可以在輸出中使用該參數。

0

您可以使用vc_add_param():

https://wpbakery.atlassian.net/wiki/spaces/VC/pages/524335/vc+add+param

,並確定該組爲 「設計選項」,如:

$attributes = array(
'type' => 'textfield', 
'heading' => __('My Field', 'lang_domain'), 
'description' => __('Description here."', 'lang_domain'), 
'param_name' => 'my_field', 
'group' => __('Design Options', 'lang_domain'), 
'admin_label' => true, 
); 

您可以添加以下這一行,你想要的任何元素:

vc_add_param('vc_element_1', $attributes); 
vc_add_param('vc_element_2', $attributes); 
etc... 

然後你複製你想添加的元素現場從以下文件夾:

js_composer/include/templates/shortcodes/vc_element_1.php 
etc... 

,並把它放在一個文件夾中在你的主題或插件。您可以反正你喜歡的編輯這些文件並添加新的領域作爲變量,也許寫一個內聯CSS等:

echo '<div style="my_field: '.$my_field.';">'; 

echo '<div style="my_field: '.$atts['my_field"].';">'; 

然後,你需要設置該文件夾,讓VC知道和使用vc_set_shortcodes_templates_dir()讀取此簡碼:

https://wpbakery.atlassian.net/wiki/spaces/VC/pages/524294/vc+set+shortcodes+templates+dir