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
--
TWikiGuest - 08 Jul 2008
Answer
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.
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 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 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