Is there a simple fix for having documents open in a new window? I'm not a php programmer so I'm not sure where to start.

Any ideas?

Comments

joelstein’s picture

There is currently no simple way to do this, other than the usual way of altering what gets written to the screen, by implementing theme_filetree in your theme.

middlenewman’s picture

Also interested. What would be the PHP modifications for this?

johnv’s picture

you could try to force_download the file. The file will appear in the bottombar (Chrome) or in a open/save popup-box (IE).

szaszg’s picture

You simply need a target="_blank" in the anchor tag, then all the linked things open up in a new window or tab depending on browser settings.
In the filetree.module at line 200:

          $url = $params['absolute'] ? file_create_url($filename) : substr(file_create_url($filename), strlen($GLOBALS['base_url'] . '/'));
          $files[$file] = array(
            'data' => l($name, urldecode($url)),
            'title' => token_replace($params['filetitle'], array('file' => $file)),
            'class' => array(_filetree_icon(pathinfo($file, PATHINFO_EXTENSION))),

If you change

            'data' => l($name, urldecode($url)),

to

            'data' => l($name, urldecode($url), array('attributes' => array('target'=>'_blank'))),

all the links open in a new window.

middlenewman’s picture

Status: Active » Fixed

Thanks! This worked for me!!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.