首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >vc_map()不提取文本字段值- Visual插件

vc_map()不提取文本字段值- Visual插件
EN

Stack Overflow用户
提问于 2015-09-24 12:38:35
回答 2查看 3.5K关注 0票数 2

我为Visual Composer创建了一个自定义元素,它几乎可以工作,但文本字段值从不更改/更新

代码:

代码语言:javascript
运行
复制
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上。

EN

回答 2

Stack Overflow用户

发布于 2015-12-08 19:46:52

您有一个错误的"value" => "Title goes here", 'vc_extend'),

应该是"value" => __('Title goes here', 'vc_extend'),

票数 1
EN

Stack Overflow用户

发布于 2017-11-10 09:02:35

如果其他人遇到这个问题,"param_name“属性的值不能包含大写字母。

将其更改为类似于"param_name" => "section_title"的内容将解决问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32761558

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档