0

I have a file download field in a node. The field displays as a simple link with the name of the file that will be downloaded, eg:

picture.png

What I want to do is rename the name on the link, i.e. I want it to stay the same but say:

Download the picture,

instead.

I have created a field--resource.tpl template, I don't know how to get started to get the name that is displayed overridden.

Here is what is in my field--field-source--resources.tpl file:

<div class="<?php print $classes; ?>"<?php print $attributes; ?>>
  <?php if (!$label_hidden): ?>
    <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
  <?php endif; ?>
  <div class="field-items"<?php print $content_attributes; ?>>
    <?php foreach ($items as $delta => $item): ?>
      <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?></div>
    <?php endforeach; ?>
  </div>
</div>

Thanks!

2

There is an easier way to approach this without having to go through the template file:

On the 'edit' page for your content type, you can set it to 'enable description field'

enter image description here

which will add a new field to your content form that will let you override the label for the file, ex:

enter image description here

This should be easier than trying to parse the template approach and will work seamlessly with other modules that interact with the file field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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