【问题标题】:Drupal 7 tokens and img tagsDrupal 7 令牌和 img 标签
【发布时间】:2018-04-23 07:00:47
【问题描述】:

我正在使用 Drupal 7、webform 和 webform2pdf 模块来创建一个申请表,一旦填写,将生成一个包含申请人所有信息的 PDF。

我遇到的问题是,我为上传 .jpg 头像和简短说明的 .pdf 设置的字段显示为链接,而不仅仅是列出内容。

我正在使用从网络表单组件生成的令牌将内容动态填充到 PDF 中。

例如 [submission:value:recent_photo]

我是否需要一种特殊的语法来显示图像而不仅仅是链接?

【问题讨论】:

    标签: drupal-7 token drupal-webform


    【解决方案1】:

    这是我找到的解决相同问题的解决方案(Drupal 7、Webform 4)。 在 MYADMINTHEME/template.php 中输入这个函数

    function MYADMINTHEME_webform_display_file($variables) {
        $element = $variables['element'];
        $current_path = current_path();
        $file = $element['#value'];
        $filemime = !empty($file) ? $element['#value']->filemime : '';
    
        if (substr_count($current_path, 'downloadpdf') && in_array($filemime, array('image/jpeg','image/gif','image/png'))){
            if ($element['#format'] == 'text')
                return !empty($file) ? webform_file_url($file->uri) : t('no upload');
    
            $url = drupal_realpath($file->uri);
            return '<img src="' . $url . '"/>';
        } else {
            $url = !empty($file) ? webform_file_url($file->uri) : t('no upload');
            return !empty($file) ? ($element['#format'] == 'text' ? $url : l($file->filename, $url)) : ' ';
        }
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-29
      • 2010-09-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多