vc_map() not extracting text field value – Visual Composer plugin

I’ve created a custom element for Visual Composer, which works almost ok but the text field value never changes / updates

Code:

Read More
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;
    }

The problem is that in the $output, $sectionTitle is not being saved /rendered – it simply stays at Title for the section

Related posts

2 comments

  1. You have a typo "value" => "Title goes here", 'vc_extend'),

    Should be "value" => __('Title goes here', 'vc_extend'),

  2. In case anyone else experiences this problem, the value of the “param_name” property cannot contain uppercase letters.

    Changing it to something like "param_name" => "section_title" will solve the problem.

Comments are closed.