【问题标题】:Add a message when a CCK filefield file is uploaded上传 CCK 文件字段文件时添加消息
【发布时间】:2023-03-11 11:56:01
【问题描述】:

我正在开发的网站刚刚遇到可用性问题,我正在考虑如何解决。

我在用作内容配置文件的节点中使用 CCK 图像字段。该字段允许用户上传头像。

我发现有些人倾向于上传图片,但无法保存节点。我猜这是因为新图像出现在那里,并且有人很容易假设它已被上传并保存并离开页面。

所以...我的一个想法是在上传图像时在 CCK 字段下方打印'image uploaded, save the the page to confirm changes' 消息。这甚至可能吗?

【问题讨论】:

    标签: drupal drupal-6 usability cck


    【解决方案1】:

    这对我有用

    ===

    function theme_filefield_widget_preview($item) {
      // Remove the current description so that we get the filename as the link.
      if (isset($item['data']['description'])) {
        unset($item['data']['description']);
      }
    
      $warning = $item['status'] ? '' : '<font color="red">Please click \'Save\' below to save these changes</font>';
    
      return '<div class="filefield-file-info">'.
               '<div class="filename">'. theme('filefield_file', $item) .'</div>'.
               '<div class="filesize">'. format_size($item['filesize']) .'</div>'.
               '<div class="filemime">'. $item['filemime'] .'</div>'.
               "<p>$warning</p>".
             '</div>';
    }
    

    【讨论】:

      【解决方案2】:

      几个选项:

      1) 自定义模块

      2) 规则和动作(动作是“显示用户消息”或类似的东西)

      【讨论】:

        【解决方案3】:

        您可以覆盖 filefield_widget.inc 文件中的 theme_filefield_widget_preview() 函数。只需将该函数复制到您的 template.php 文件,将其重命名为 phptemplate_filefield_widget_preview(),然后根据需要进行任何更改。

        //你也可以尝试重命名为[MY_THEME]_filefield_widget_preview()

        function phptemplate_filefield_widget_preview($item) {
        
          // Remove the current description so that we get the filename as the link.
          if (isset($item['data']['description'])) {
            unset($item['data']['description']);
          }
        
          return '<div class="filefield-file-info">'.
                   '<div class="filename">'. theme('filefield_file', $item) .'</div>'.
                   '<div class="filesize">'. format_size($item['filesize']) .'</div>'.
                   '<div class="filemime">'. $item['filemime'] .'</div>'.
                   // Custom block
                   '<div class="my-custom-class">'. t('Changes made in this table will not be saved until the form is submitted.') .'</div>'.
        
                 '</div>';
        }
        

        【讨论】:

        • 我似乎无法让它工作......但这让我想到尝试一个 jQuery 解决方案来操作描述字段。
        猜你喜欢
        • 2017-12-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多