Tags:
create new tag
, view all tags

Question

Is there a way to display the last modified date of an attachment on another page, preferably on a default-like TWiki installation?

Example: There is a file some.doc attached to a page FilePage, among with many other attachments. I would like to show the modified date of that specific file on some other page, displaying something like this:

Environment

TWiki version: TWikiRelease04x00x04
TWiki plugins:  
Server OS: RedHat Linux
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories: Missing functionality

-- TWikiGuest - 08 Jul 2008

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

The attachment info is in the META area of the topics, and you can see it by adding ?raw=debug to the view URL, like this. For the dummy attachment on this topic, it looks like:

%META:FILEATTACHMENT{name="dummy.txt" attachment="dummy.txt" attr="" comment="Sample attachment" date="1216162122" path="C:\Documents and Settings\morganse\Desktop\dummy.txt" size="12" stream="C:\Documents and Settings\morganse\Desktop\dummy.txt" tmpFilename="/tmp/dYS1PstyKQ" user="Main.SeanCMorgan" version="1"}%

See TWikiMetaData#META_FILEATTACHMENT for details of what all these entries mean.

But it seems to be hard to get at that data to put it into another topic:

  • VarMETA will display attachment info, and you can create a template to format its output the way you want. But it only works for the current topic.
  • QuerySearch lets you find topics with attachments, but I can't see how to get the attachment name in the result.
  • FormattedSearch won't let you access the meta data with a $pattern expression. Its documentation suggests using $formfield, but the attachments aren't in form fields.

You might be able to get this to work with VarINCLUDE, by grabbing the raw version with its URL. Your server would have to allow URL includes for that to work. Don't include it with a simple topic reference, or you lose the meta data again. Use the print version of the URL so there's less overhead and better performance, e.g., like this. Then use INCLUDE's $pattern matching to extract the fields you want. You will also want to use SpreadSheetPlugin#FuncFORMATTIME to convert that epoch time into something human-readable.

If that doesn't work, the file names and timestamps for the attachments are all available at the operating system level. On second thought, it might be easier to just write an application to grab it that way :-).

-- SeanCMorgan - 15 Jul 2008

> FormattedSearch won't let you access the meta data with a $pattern expression

Well, that's what the documentation says. But it seemed to work anyway (view raw):

  • dummy.txt • updated 1216162122

And after converting the timestamp and linking to the attachment:

I don't know why it only showed one attachment, even though I used the multiple attribute.

-- SeanCMorgan - 17 Jul 2008

Or use AttachmentListPlugin

-- SeanCMorgan - 31 Jul 2008

Or the ATTACHMENT tag in DBCachePlugin.

-- LynnwoodBrown - 01 Aug 2008

The multiple parameter only works on topic text, not meta data.

-- PeterThoeny - 17 Aug 2008

 
Change status to:
Topic attachments
I Attachment Action Size Date Who Comment
GIFgif AddAction.gif manage 0.9 K 2008-07-17 - 18:03 SeanCMorgan  
Texttxt dummy.txt manage 0.1 K 2008-07-15 - 22:48 SeanCMorgan Sample attachment
Texttxt dummy2.txt manage 0.1 K 2008-07-17 - 18:01 SeanCMorgan 2nd sample
Topic revision: r6 - 2008-08-17 - PeterThoeny
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.