Tags:
create new tag
view all tags

Question

I would like to modify the way the file links appear in the Attachment table at the bottom of each topic. Specifically, I would like them to include some URL parameter (version number, time stamp, etc.) that will ensure they point to the most recent version of the attachment. Can someone tell me where those links are written/processed in the TWiki core files? Any suggestion on how to implement would also be welcomed.

Environment

TWiki version: TWikiRelease04x02x00
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server: Apache 2.2.3
Perl version:  
Client OS:  
Web Browser:  
Categories: Platform, Version control

-- GarySprague - 21 Aug 2008

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

It is a template file templates/attachtables.tmpl. If you are using PatternSkin (default) look at attachtables.pattern.tmpl.

-- ArthurClemens - 21 Aug 2008

Thanks, Arthur! That was a very easy change once I found the file...Out of curiosity, what's the benefit of not using the viewfile script to access attachments? Is there a slight performance loss with that script versus the straight pub directory access?

-- GarySprague - 22 Aug 2008

Yes, performance is the main reason.

-- PeterThoeny - 23 Aug 2008

viewfile is used to protect images from directly viewing. It uses TWiki access checking, but has a performance penalty.

-- ArthurClemens - 24 Aug 2008

Rather than directly modify the attachtables.tmpl file, I thought I would use the guidelines under http://twiki.org/cgi-bin/view/TWiki/TWikiTemplates#TMPL_INCLUDE_recursion_for_piece to isolate the template definition I wanted to change, namely "ATTACH:files:fow(basic)." So I created a new attachtables template file called attachtables.rsf.tmpl (with my Main.TWikiPreferences showing SKIN = rsf, pattern), and entered the following text in that file:

%TMPL:INCLUDE{"attachtables"}%

%{ A basic row definition, for attachment table and attach screen }%
%{ Use %A_URL% instead of %PUBURLPATH%/%WEB%/%TOPIC%/%A_FILE% to get a viewfile link }%
%TMPL:DEF{ATTACH:files:row(basic)}%| %A_ICON%<span class="twikiHidden">%A_EXT%</span> | <a href="%A_URL%">%A_FILE%</a> | <a hre
f="%SCRIPTURLPATH{"attach"}%/%WEB%/%TOPIC%?filename=%ENCODE{"%A_FILE%"}%;revInfo=1" title="%MAKETEXT{"change, update, previous
revisions, move, delete..."}%" rel="nofollow">%MAKETEXT{"manage"}%</a> |  %A_SIZE%|<span class="twikiNoBreak">%A_DATE%</span> |
%A_USER%  |%A_COMMENT%  |%TMPL:END%

Unfortunately, this led to really funky rendering of the attachment table. The attachtables.pattern.tmpl also has an INCLUDE of "attachtables" in it, and I'm wondering if that's what is causing the issue? Basically, I want to include everything that is in attachtables.pattern.tmpl, and everything that's in attachtables.tmpl EXCEPT the one definition of "ATTACH:files:row(basic)". But generally speaking, I just want to be able to preserve this change to the attachment table rendering even if we upgrade our core TWiki installation. Any suggestions of how to best go about this?

Thanks!

-- GarySprague - 02 Sep 2008

> The attachtables.pattern.tmpl also has an INCLUDE of "attachtables" in it,

That does seem to be the way it works (at least it did for me, when I tweaked a different template).

> %{ Use %A_URL% instead of ...

Those variables inside comments look kind of dangerous: if they get interpreted, the template might break.

Maybe remove all the %'s inside %{..}%? Or just temporarily remove those comments?

-- SeanCMorgan - 01 Oct 2008

Seems to be answered, closing this after more than 30 days of inactivity. Please feel free to re-open if needed.

-- PeterThoeny - 07 Nov 2008

Change status to:
Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r8 - 2008-11-07 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.