SID-01638: Find number of attachments
| Status: |
Answered |
TWiki version: |
|
Perl version: |
|
| Category: |
CategoryAttachments |
Server OS: |
|
Last update: |
13 years ago |
I need to calculate the number of attachments attached to a particular topic. Then the calculated number should be displayed next to the topic name. My aim is to find out the number of attachments without opening that topic. How can I do this?
--
Karthikeyan Elango - 2013-02-08
Discussion and Answer
Use a query search. Details in
QuerySearch,
VarSEARCH,
FormattedSearch.
Example for this topic:
- Topic SID-01638 has 2 attachments.
(View the raw text to see how this works)
--
Peter Thoeny - 2013-02-08
As per your advice reverting back from "SID-01640: Store no. of attachments in a variable" to here.
QUESTION 1:My original question was to count the attachments and store it in a variable but, as you mentioned in "SID-01639: Query not executed" I need to upgrade TWIKI to get the "$query(attachments.arraysize)" thing working. UPGRADING TWIKI IS OUT OF MY CONTROL. Is there another way to just test the existence of at least one attachment (no need to count the exact number) without the "$query(attachments.arraysize)" thing.
QUESTION 2: I tried using
%SEARCH{
topic = "(Some other topic's name other than current topic)"
scope="all"
nonoise = "on"
format="Topic $topic has $query(attachments.arraysize) attachments."
}%
But I dont get any output for this. (Even if the query is not executed, at least the correct topic name should have been displayed)
--
Karthikeyan Elango - 2013-02-11
Q1: Upgrade TWiki, or
hire a consultant to backport the
$query() feature to
FormattedSearch.
Q2: You need to search for something, e.g.
%SEARCH{ "something" topic="FooBar" ... }%. Details in
VarSEARCH.
--
Peter Thoeny - 2013-02-12
Actually, on Q1, you
might me able to search for
"%META:FILEATTACHMENT" on the topic. If no search it there are no attachments; if there is a search hit, there are.
--
Peter Thoeny - 2013-02-12
Once again as per your advice reverting to this topic from SID-01641: Access Directory table(attachments list table)
As a workaround to count the number of attachments in a topic(other than upgrading TWIKI), I am trying to count the number of rows in the Directory table(attachments list table at the bottom of a topic having attachments). Could you please verify the feasibility of this technique and provide an example?
--
Karthikeyan Elango - 2013-02-12
Changing status to asked
--
Karthikeyan Elango - 2013-02-12
The attachment table is generated dynamically. I don't think it is possible to count the number of attachments without a
$query().
--
Peter Thoeny - 2013-02-12
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.