1

I want to add a "View File" button in Drupal 7 website. A PDF file associated with it, should open in new tab. The problem is that this button should be added inside a block.

I want to ask that how to add a button in a block?

1
  • Is this a node's file field? Commented Dec 11, 2016 at 4:26

1 Answer 1

1

For multiple files:

  1. Create a View
  2. Add your file field and set "Formatter" as "URL to file".
  3. Try rewriting the field as <a href="[YOUR_FIELD]" target="_blank">Go to file</a>
  4. You could embed this view in a block as php. The simplest way would be to use the PHP Filter located in D7 core, but there are some reasons not to use it.

For just one file, use:

<a href="/sites/default/files/your-file.pdf" target="_blank">Go to file</a>

Your Answer

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

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