【问题标题】:Visual Composer custom shortcode template - custom_markup display user inputVisual Composer 自定义简码模板 - custom_markup 显示用户输入
【发布时间】:2015-12-21 03:03:13
【问题描述】:

我创建了一些简码元素。现在我想自定义后端编辑器中元素的外观。

从 VC-Pagebuilder wiki 的 description 得知,我可以为此使用“custom_markup”参数。

对于简单的 html,它可以正常工作。但我无法在短代码后端元素中显示用户输入。

<?php
    add_shortcode('simpletext', 'simpletext_shortcode');
    add_action('vc_before_init', 'simpletext_vc');

    // Frontend output

    function simpletext_shortcode($atts, $content = '') {
      ob_start();
      set_query_var('content', $content);
      get_template_part('components/content', 'simpletext');
      return ob_get_clean();
    }

    // Backend
    function simpletext_vc() {
      vc_map(array(
        "name" => "Einfacher Text",
        "base" => "simpletext",
        "class" => "",
        "icon" => get_template_directory_uri() ."/images/vc_icons/simpletext_icon.png", 
    "custom_markup" => '{{ content }}', // try to display the user input
    "category" => "Text",
    "params" => array(
      array(
        "param_name" => "content",
        "heading" => "Inhalt",
        "description" => "Inhalt des Elements.",
        "holder" => "div",
        "type" => "textarea_html"
      )
    )
   ));
  }
?>

感谢您的帮助。

【问题讨论】:

标签: php wordpress wordpress-theming shortcode custom-wordpress-pages


【解决方案1】:

在 Page Builder 中,它们的旧版本非常相似,您可以使用 admin_label 为每个参数设置一个 true 或 false 值,以显示用户关闭弹出窗口后输入的值。在这种情况下也可以工作。

类似这样的:

"params" => array(
      array(
        "param_name" => "content",
        "heading" => "Inhalt",
        "description" => "Inhalt des Elements.",
        "holder" => "div",
        "type" => "textarea_html",
        "admin_label" => true
      )
    )

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多