Drupal 上载CCK文件字段文件时添加消息
我正在开发的一个网站出现了一个可用性问题,我正在思考如何解决这个问题 我在一个用作内容配置文件的节点中使用CCK imagefield。该字段允许用户上传化身 我发现有一些人倾向于上传图像,但无法保存节点。我猜这是因为新的图像出现在那里,人们很容易就认为它已经被上传和保存,然后离开页面 所以。。。我的一个想法是在上传图像时,在CCK字段下方打印一条“上传图像,保存页面以确认更改”的消息。这可能吗?两个选项: 1) 自定义模块 2) 规则和操作(操作是“显示用户消息”或类似内容)耦合选项: 1) 自定义模块Drupal 上载CCK文件字段文件时添加消息,drupal,drupal-6,usability,cck,Drupal,Drupal 6,Usability,Cck,我正在开发的一个网站出现了一个可用性问题,我正在思考如何解决这个问题 我在一个用作内容配置文件的节点中使用CCK imagefield。该字段允许用户上传化身 我发现有一些人倾向于上传图像,但无法保存节点。我猜这是因为新的图像出现在那里,人们很容易就认为它已经被上传和保存,然后离开页面 所以。。。我的一个想法是在上传图像时,在CCK字段下方打印一条“上传图像,保存页面以确认更改”的消息。这可能吗?两个选项: 1) 自定义模块 2) 规则和操作(操作是“显示用户消息”或类似内容)耦合选项: 1)
2) 规则和操作(操作是“显示用户消息”或类似内容)您可以从filefield\u widget.inc文件中重写theme\u filefield\u widget\u preview()函数。只需将函数复制到template.php文件中,将其重命名为phptemplate_filefield_widget_preview(),然后根据需要更改任何内容 //您还可以尝试重命名为[MY_THEME]\u filefield\u widget\u preview()
函数phptemplate\u文件字段\u小部件\u预览($item){
//删除当前描述,以便我们获得文件名作为链接。
如果(isset($item['data']['description'])){
未设置($item['data']['description']);
}
返回“”。
''.theme('filefield_file',$item)。''。
''.format_size($item['filesize'])。'。
“.$item['filemime']”。
//自定义块
''.t('在提交表单之前,此表中所做的更改不会被保存。')。'。
'';
}
您可以从filefield\u widget.inc文件中重写theme\u filefield\u widget\u preview()函数。只需将函数复制到template.php文件中,将其重命名为phptemplate_filefield_widget_preview(),然后根据需要更改任何内容
//您还可以尝试重命名为[MY_THEME]\u filefield\u widget\u preview()
函数phptemplate\u文件字段\u小部件\u预览($item){
//删除当前描述,以便我们获得文件名作为链接。
如果(isset($item['data']['description'])){
未设置($item['data']['description']);
}
返回“”。
''.theme('filefield_file',$item)。''。
''.format_size($item['filesize'])。'。
“.$item['filemime']”。
//自定义块
''.t('在提交表单之前,此表中所做的更改不会被保存。')。'。
'';
}
这就是我的工作原理
===
函数主题\文件字段\小部件\预览($item){
//删除当前描述,以便我们获得文件名作为链接。
如果(isset($item['data']['description'])){
未设置($item['data']['description']);
}
$warning=$item['status']?'':'请单击下面的“保存\”保存这些更改';
返回“”。
''.theme('filefield_file',$item)。''。
''.format_size($item['filesize'])。'。
“.$item['filemime']”。
“$warning”。
'';
}
这就是我的工作原理
===
函数主题\文件字段\小部件\预览($item){
//删除当前描述,以便我们获得文件名作为链接。
如果(isset($item['data']['description'])){
未设置($item['data']['description']);
}
$warning=$item['status']?'':'请单击下面的“保存\”保存这些更改';
返回“”。
''.theme('filefield_file',$item)。''。
''.format_size($item['filesize'])。'。
“.$item['filemime']”。
“$warning”。
'';
}
我似乎无法让它工作。。。但这让我想到尝试一个jQuery解决方案来操作描述字段。我似乎无法让它工作。。。但这让我想到尝试使用jQuery解决方案来操作描述字段。
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>';
}
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>';
}