Visual Composer 自定义简码模板 - custom_markup显示用户输入

Visual Composer custom shortcode template - custom_markup display user input

提问人:auerc89 提问时间:9/24/2015 最后编辑:Ruveeauerc89 更新时间:6/8/2023 访问量:1689

问:

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

从 VC-Pagebuilder 的 wiki 描述中,我得知我可以为此使用“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页面

评论

0赞 Tim Hallman 1/27/2020
你有没有想过这一点?我到处搜索,到目前为止还没有找到解决方案。
0赞 auerc89 1/29/2020
不。。。。不好意思。。。
0赞 Tim Hallman 1/29/2020
我这里有一个类似的问题:stackoverflow.com/questions/59933956/......
0赞 Dmitry Leiko 1/30/2020
你能在这里提供一些图片吗?
1赞 auerc89 2/1/2020
我的问题是 ~5 岁。请检查以下问题 stackoverflow.com/questions/59933956/...

答:

0赞 Octav Iosif 12/4/2021 #1

在页面构建器中,它们的旧版本非常相似,您可以为每个参数使用 true 或 false 值,以显示用户关闭弹出窗口后输入的值。在这种情况下也可能有效。admin_label

像这样的东西:

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