Jump to content

[Solved] File list in admin area


Recommended Posts

One of the fields that I have is 'files' - a self-exlanatory multiple-files type of field, used mostly for PDFs. When I click on the file title in the backend it used to open this file in a new tab (using the browser's built-in PDF viewer). Somewhere in the last few updates I did, this behaviour changed and now the files are automatically downloaded.

How to manipulate this, I assume it is a matter of adding target='_blank' to somewhere in the code, but not show where?

Again, this is for the backend/admin area of the website only. I am aware that you can do this with right mouse click (and old cmd or ctrl click doesn't work either) but it is not fully streamlined for my specific use case. Any suggestions welcome.

Link to comment
Share on other sites

You can use this hook to do what you want:

$wire->addHookBefore("InputfieldFile::render", function (HookEvent $event) {
  $inputfield = $event->object;
  if ($inputfield->name !== 'your_fields_name') return;

  $inputfield->appendMarkup .= "<script>
  document.currentScript.parentElement.querySelectorAll('a.InputfieldFileName').forEach(function(link) {
    if (!link.href.endsWith('.pdf')) return;


  • Thanks 1
Link to comment
Share on other sites

  • encho changed the title to [Solved] File list in admin area

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...