rejetto forum

How to download a file in a new page?

0 Members and 1 Guest are viewing this topic.

Offline stonecooper

  • Occasional poster
  • *
    • Posts: 8
    • View Profile
Does anyone know how to download a file in a new page? In 2.3 279 default.dpl, when you click the file, the file is donwload directly. How could change the templates when click the file, it will jump to a new page, and this page I will write some warming message and another link to the file, this link is the real link for the file.

I modidied the default.tpl file link to ~files.lst like this:
Code: [Select]
file=folder=link|private]
<tr class='{.if|{.mod|{.count|row.}|2.}|even.}'><td>
        <input type='checkbox' class='selector' name='selection' value='%item-url%' {.if not|{.or|{.get|can delete.}|{.get|can access.}|{.get|can archive item.}.}|disabled='disabled'.} />
{.if|{.get|is new.}|<span class='flag'>&nbsp;NEW&nbsp;</span>.}
{.if not|{.get|can access.}|<img src='/~img_lock'>.}
<a [color=red]href="~files.lst"[/color]><img src="%item-icon%"> %item-name%</a>
{.if| {.?search.} |{:{.123 if 2|<div class='item-folder'>{.!item folder.} |{.breadcrumbs|{:<a href="%bread-url%">%bread-name%/</a>:}|from={.count substring|/|%folder%.}/breadcrumbs.}|</div>.}:} .}
{.123 if 2|<div class='comment'>|{.commentNL|%item-comment%.}|</div>.}

And then modified the filelist.tpl to :
Code: [Select]
%files%

[files]
%list%

[file]
%item-url%


The new page will display when you click the file, but the new page contain all the files %item-url% in the current folder, I think this is because the marco %list% expand to all the file list in the current folder.

Any one konw how to implement this feature?


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
you should link not "~files.lst" but "?mode=section&id=download&url={.encodeuri|%item-url%.}"

then you add a section to the template

Code: [Select]
[download]
Please <a href='{.?url.}'>click here</a> to download

i didn't test it! good luck ^^


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
you should link not "~files.lst" but "?mode=section&id=download&url={.encodeuri|%item-url%.}"

Why use "?mode=section&id=download&url={.encodeuri|%item-url%.}" when you could just use "~download?url={.encodeuri|%item-url%.}" ?
« Last Edit: August 30, 2011, 03:25:21 PM by raybob95 »



Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
the "~download" form is deprecated.
You may not find it in HFS 3.


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
Lol then I may not be able to upgrade to HFS 3 when the time comes because all my pages use that   :D   I actually have any containing url ?mode=section forward to ~deny on my site.  I just thought it gave cleaner looking URLs... Why would it become deprecated?
« Last Edit: September 04, 2011, 12:15:18 AM by raybob95 »