上传 CCK 文件字段文件时添加消息

发布于 2024-10-24 03:18:30 字数 234 浏览 7 评论 0原文

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

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

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

所以...我的一个想法是在上传图像时在 CCK 字段下方打印一条“图像已上传,保存页面以确认更改” 消息。这可能吗?

Just got a usability issue with a site I'm developing, and I'm pondering how to address it.

I'm using a CCK imagefield within a node that is used as a content profile. The field allows users to upload an avatar.

I've found that a few people tend to upload an image, but fail to save the node. I guess it's because the new image appears there, and it's easy for someone just to assume it's been uploaded and saved and navigate away from the page.

So... one idea I had was to print a 'image uploaded, save the the page to confirm changes' message below the CCK field when an image is uploaded. Is this even possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

悸初 2024-10-31 03:18:30

这对我有用

===

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>';
}

That's what worked for me

===

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>';
}
蓝眼泪 2024-10-31 03:18:30

几个选项:

1)自定义模块

2)规则和操作(操作是“显示用户消息”或类似的内容)

Couple options:

1) Custom module

2) Rules and actions (action is 'show user message' or something similar)

缱倦旧时光 2024-10-31 03:18:30

您可以覆盖 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>';
}

You can override the theme_filefield_widget_preview() function from the filefield_widget.inc file. Just copy the function to your template.php file, rename it to phptemplate_filefield_widget_preview(), then change anything as necessary.

// Also you can try to rename to [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>';
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文