I am trying to build a simple Views Accordion view to display support documents. I created a simple content type with three fields: Group (my category), Document Title, and File. The only way I can get the attached file to appear is by inserting the field Content: File. That links to the file and displays the little PDF icon, but shows the actual filename as the hyperlink text. I would like to use the Document Title field contents as the hyperlink text, but can't figure out the proper way to do this. I have tried hiding the file from display and rewriting the output of the Document Title field to be something like: <a href="[field_file]">[title]</a> However, it appears Drupal is rendering the link to the file instead of inserting the path to the file, as it shows the PDF icon and the filename.

Is there a way to override the hyperlink text when showing an attached file?

  • The what where now? – eljefejb Jun 28 '13 at 23:16

Certainly, you just have to use the correct formatter to start with. I am guessing that you are using the "Generic Files" one. If you instead select "Path to File" you can then use rewrite output the way you mention in your question. Little gotcha: make sure the title field you are using isn't "linked to its node" or things will get odd :)

(Note, I am suggesting you rewrite the file field instead of the title field)

  • Bingo! That seems to have been the issue. Rewriting the title field seems to be working. I have the file field excluded from display, and rewriting the title field to link to [field_file]. Thanks for the help! – eljefejb Jul 1 '13 at 18:31

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.