2011-03-18 31 views
0

剛剛發生了一個我正在開發的網站的可用性問題,我正在思考如何解決它。當CCK文件上傳文件上傳時添加一條消息

我在用作內容配置文件的節點內使用CCK圖像字段。該字段允許用戶上傳頭像。

我發現有一些人傾向於上傳圖片,但無法保存節點。我想這是因爲新圖像出現在那裏,並且很容易讓某人假設它已經被上傳並保存並離開頁面。

所以......我想到的一個想法是在上載圖像時在CCK字段下面打印'image uploaded, save the the page to confirm changes'消息。這甚至有可能嗎?

回答

1

夫婦選擇:

1)自定義模塊

2)規則和動作(動作

1

您可以從覆蓋theme_filefield_widget_preview()函數 '顯示用戶信息' 或類似的東西) filefield_widget.inc文件。只需將該函數複製到您的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>'; 
} 
+0

我似乎無法給什麼工作讓這個工作...但它讓我想到嘗試一個jQuery解決方案來操縱描述字段。 – james6848 2011-03-21 14:56:33

2

這對我來說

===

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