I have created a download list, based on the file list component. I have a requirement to provide functionality that allows the content editor to determine whether, on click, a file should be downloaded, opened in a new tab or opened in the current tab.

I started by creating a droplist field on the template on which I set the source to an options folder I'd created containing the above choices.

From here, I intended to set rules on the file to determine how it should behave based on what was selected in the droplist but I realised that this functionality wasn't available in the rules engine.

Here's a picture of my variant, if it's useful:

enter image description here

How can I achieve this?

  • What are your file types? PDF? jpg? – Richard Seal Jun 18 '19 at 18:17
  • 1
    Have you looked into using the download attribute on a tags? w3schools.com/tags/att_a_download.asp – Richard Seal Jun 18 '19 at 18:23
  • Yeah, I did have a look at the download attribute but I decided to see if there was a solution available within Sitecore due to the lack of legacy browser support. I don't think it's necessarily a huge issue, but I think my options seem to be limited, so I'll play around with your suggestion above. Cheers Richard – Jack Hayward Jun 18 '19 at 20:10
  • 1
    That won't work on IE, if you need support for that. There is nothing built into Sitecore to support this, and you need to set the Content-Disposition header to force a download: jammykam.wordpress.com/2015/11/16/force-download-of-media-files. You could follow a similar solution for opening in a new tab by using a specific CSS class and Javascript. – jammykam Jun 18 '19 at 20:12
  • Perfect, I'll have a play with this tomorrow. Many thanks for your response. – Jack Hayward Jun 18 '19 at 20:49

Your Answer

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

Browse other questions tagged or ask your own question.