我为Visual Composer
创建了一个自定义元素,它几乎可以工作,但文本字段值从不更改/更新
代码:
vc_map( array(
"name" => __("BS Card - title and list", 'vc_extend'),
"description" => __("Add a card with title and list", 'vc_extend'),
"base" => "CardTitleList",
"class" => "",
"controls" => "full",
"icon" => plugins_url('assets/asterisk_yellow.png', __FILE__), // or css class name which you can reffer in your css file later. Example: "vc_extend_my_class"
"category" => __('Content', 'js_composer'),
"params" => array(
array(
"type" => "textfield",
"holder" => "div",
"class" => "",
"heading" => __("Title", 'vc_extend'),
"param_name" => "sectionTitle", // <-- doesn't seem to read this
"value" => "Title goes here", 'vc_extend'),
"description" => __("Title for the section", 'vc_extend')
),
array(
"type" => "colorpicker",
"holder" => "div",
"class" => "",
"heading" => __("Background color", 'vc_extend'),
"param_name" => "color",
"value" => '#ffffff', //Default background color
"description" => __("Choose background color", 'vc_extend')
),
array(
"type" => "textarea_html",
"holder" => "div",
"class" => "",
"heading" => __("Content", 'vc_extend'),
"param_name" => "content",
"value" => __("<ul><li>list item 1</li><li>list item 2</li><li>list item 3</li><li>list item 4</li></ul>", 'vc_extend'),
"description" => __("Enter your content.", 'vc_extend')
),
)
) );
public function renderCardTitleList( $atts, $content = null ) {
extract($atts = vc_map_get_attributes( 'CardTitleList', $atts ));
$content = wpb_js_remove_wpautop($content, true); // fix unclosed/unwanted paragraph tags in $content
// in here {$sectionTitle} is not saved rendered as same as in text box
$output = "<div class='card__title-list'><div style='background:{$color};'><h2>{$sectionTitle}</h2>{$content}</div></div>";
return $output;
}
问题在于,在$output
中,$sectionTitle
并没有被保存--它只是停留在Title for the section
上。
发布于 2015-12-08 19:46:52
您有一个错误的"value" => "Title goes here", 'vc_extend'),
应该是"value" => __('Title goes here', 'vc_extend'),
发布于 2017-11-10 09:02:35
如果其他人遇到这个问题,"param_name“属性的值不能包含大写字母。
将其更改为类似于"param_name" => "section_title"
的内容将解决问题。
https://stackoverflow.com/questions/32761558
复制相似问题