【发布时间】:2017-08-09 17:25:23
【问题描述】:
想知道,如何在 Visual Composer 中为“设计选项”组添加新选项。在我的情况下,我需要添加容器元素宽度。
提前致谢
【问题讨论】:
想知道,如何在 Visual Composer 中为“设计选项”组添加新选项。在我的情况下,我需要添加容器元素宽度。
提前致谢
【问题讨论】:
我不确定您是否可以为所有元素全局设置自定义选项,但如果您正在构建自定义元素,您可以执行以下操作:
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' ),
),
),
) );
然后您可以在输出中使用该参数。
【讨论】:
你可以使用 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
【讨论】: