1

We have a Commerce Product Display for a Product Variation. If you're not familiar with Commerce Kickstart, it's basically just a form to add an item to a shopping cart. Each Product Display includes links to various PDF documents. The display format for the PDF field is 'table of files'. It works, however it looks clunky.

I'm having trouble locating the tpl or inc file that controls formatting for this type of field ('Table Of Files'). We don't want to globally change table display, we just want to alter it on this one Display.

Where is the php located to theme this? Or is there a function I need to add to my theme to hook into that display?

Specifically, we want to:

  1. Get rid of the header.
  2. Get rid of the file size column.

2 Answers 2

0

I am not sure which tpl.php file you will need to override, but you can try to "inspect" for it using Devel Themer and then override it with your own tpl.php.

This doc page has some common overrides and you can kind of get the override pattern. I am guessing you will need to something like field--field-name--content-type.tpl.php.

0

If you're using core's file.module, then there is no .tpl.php, you want to override this function in your theme:

/**
 * Returns HTML for a file attachments table.
 *
 *     @param $variables
 *   An associative array containing:
 *   - items: An array of file attachments.
 *
 * @ingroup themeable
 */
function theme_file_formatter_table($variables) {
  $header = array(t('Attachment'), t('Size'));
  $rows = array();
  foreach ($variables['items'] as $delta => $item) {
    $rows[] = array(
      theme('file_link', array('file' => (object) $item)),
      format_size($item['filesize']),
    );
  }

  return empty($rows) ? '' : theme('table', array('header' => $header, 'rows' => $rows));
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.