Question
Hi, I'd like to list all the attachments of one of my topics on my main page (in a bullet list).
On the topic page itself there already is such a list of all the attached files, but to copy and paste the code to the main page doesn't work because the % ATTACHURL % variable is resolved incorrectly.
The same goes for formatted search (with a regular expression that prints everything between the first bullet and the next double newline).
A simple perl s/% ATTACHURL %/MyTopic/g; would do the job, but is there any way to include perl code into the TWiki syntax?
Or is there a different way to list attachments of another topic?
Thanks for help,
Tamara
Environment
--
TamaraUlrich - 29 Nov 2006
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.
If you already have a formatted list in another topic, then the easiest way would be to wrap that list in a named section:
%STARTSECTION{"attachmentlist"}%
* First attachment is %ATTACHURL%/attachment1
* Second attachment is %ATTACHURL%/attachment1
%ENDSECTION{"attachmentlist"}%
In your main page, you then can include that list:
%INCLUDE{"MyTopic" section="attachmentlist"}%
You could even pick the attachments from TWikis automatic attachment table with
FormQueryPlugin - See
HowToGetFileAttachmentDetails for a similar example, or
FormQueryPluginTutorial for the general procedure.
--
HaraldJoerg - 29 Nov 2006
Not sure if
%ATTACHURL%/attachment1 works if included into another topic. In case it does not work, use
%PUBURL%/%WEB%/%TOPIC%/attachment1. See
FileAttachment docs.
--
PeterThoeny - 29 Nov 2006
%ATTACHURL%/attachment1 actually did work in the include statement. The problem was that I need that bullet list for the
TreeBrowserPlugin, which requires lists on different levels (i.e. with 3,6,9,... spaces before the aterisk). The list that I got from the include statement has only three spaces (level one list) and I couldn't find out how to add more.
So I installed the
FormQueryPlugin and used the following code to create an attachment-tree:
%FORMQUERY{name=LevelOne search="name='LevelOneTopic'" extract="attachments"}%
%FORMQUERY{name=LevelTwo search="name='LevelTwoTopic'" extract="attachments"}%
%TREEBROWSER{"file" title="*Example Tree*" shared="left"}%
* *Level One*
* *Level Two*
%SHOWQUERY{query=LevelTwo header="" footer="" format=" * [[%PUBURL%/%WEB%/$_up.topic/$name][$comment]]"}%
%SHOWQUERY{query=LevelOne header="" footer="" format=" * [[%PUBURL%/%WEB%/$_up.topic/$name][$comment]]"}%
--
TamaraUlrich - 30 Nov 2006
related:
--
VickiBrown - 25 Mar 2008
See also
AttachmentListPlugin.
--
ArthurClemens - 25 Mar 2008