设置Drupal附件表的主题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了设置Drupal附件表的主题相关的知识,希望对你有一定的参考价值。

Create theme override file: `upload_attachments.tpl.php` in your theme directory.

[CSS styles](http://snipplr.com/view/11848)
  1. <?php
  2. /**
  3.  * Themed attachments table
  4.  */
  5. $header = array(t('File name'), t('Size'));
  6. $rows = array();
  7. foreach ($files as $file) {
  8. if ($file->list) {
  9. $type = explode('/', $file->filemime);
  10. // Quick fix. Should use some kind of make_safe_for_css() function.
  11. $type = str_replace('.', '-'. $type[1]);
  12. $href = check_url(($file->fid ? file_create_url($file->filepath) : url(file_create_filename($file->filename, file_create_path()))));
  13. /* To do:
  14.   if (!empty($file->description)) {
  15.   $text = check_plain($file->description) . '<br /><span class="filename">'.$file->filename.'</span>';
  16.   }
  17.   else {
  18.   $text = check_plain($file->filename);
  19.   }
  20.   */
  21. $text = check_plain($file->description ? $file->description : $file->filename);
  22. // Because the drupal format_size function doesn't round far enough to be smooth.
  23. $size = $file->filesize;
  24. $suffix = t('bytes');
  25. if ($size >= 1024) {
  26. $size = round($size / 1024, 0);
  27. $suffix = t('KB');
  28. }
  29. if ($size >= 1024) {
  30. $size = round($size / 1024, 0);
  31. $suffix = t('MB');
  32. }
  33.  
  34. $size = array('data' => t('%size %suffix', array('%size' => $size, '%suffix' => $suffix)), 'class' => 'size');
  35.  
  36. if ($type == 'jpeg' ) {
  37. $text = array('data' => l($text, $href, array('title' => 'Right click to download', 'class' => 'thickbox'), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = TRUE), 'class' => $type);
  38. }
  39. else {
  40. $text = array('data' => l($text, $href, array('title' => 'Right click to download'), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = TRUE), 'class' => $type);
  41. }
  42. $rows[] = array($text, $size);
  43. }
  44. }
  45.  
  46. if (count($rows)) {
  47. print '<div class="attachments">'. theme('table', $header, $rows, array('class' => 'attachments'), 'Downloadable files') .'</div>';
  48. }

以上是关于设置Drupal附件表的主题的主要内容,如果未能解决你的问题,请参考以下文章

CSS 上传附件表的Drupal自定义样式

上传附件表的Drupal自定义样式

Drupal 6 视图 2:PHP 片段

DRUPAL,视图:我无法从视图设置中更改主题

Drupal 7 发送不带附件的电子邮件

Javascript代码片段在drupal中不起作用