SID-01390: Show text if the topic as attachment
| Status: |
Answered |
TWiki version: |
4.3.2 |
Perl version: |
|
| Category: |
CategoryAttachments |
Server OS: |
|
Last update: |
14 years ago |
I want to create an include topic at the top of some other topics
This include topic should show some text if the Topic that includes it has an attachment, otherwise it should show another text.
I couldn't create the right SEARCH query for that.
Please help.
--
DanielAjoy - 2012-01-31
Discussion and Answer
I figured out I can use this to produce an X if the current topic has an attachment.
%SEARCH{"name='%ATTATOPIC%' AND attachments[attr!='h']" type="query" nonoise="on" format="X" }%
But then I need to include that into an IF of the form
%IF{"SSSSSSSSSSSS = 'X'" then="A" else="B"}%
I can't figure how to do that.
--
DanielAjoy - 2012-01-31
You don't really need the SEARCH, you can do the test directly in the IF condition.
Alternatively, place the SEARCH inside the IF condition. In this case, the SEARCH gets evaluated before the IF due to inside out eval rule. in the if you can do a string compare to test for the text specified in the SEARCH format.
If you use variables in the IF then and else, you probably need to escape them, such as
then="$percntINCLUDE{\"SomeStuff\"}$percnt".
Details in
VarSEARCH,
FormattedSearch,
QuerySearch,
VarIF,
IfStatements
--
PeterThoeny - 2012-01-31
You say:
You don't really need the SEARCH, you can do the test directly in the IF condition.
I don't see how. like this? :
%IF{" name='%ATTATOPIC%' AND attachments[attr!='h']" type="query" nonoise="on" format="X" = 'X'" then="A" else="B"}% </verbatim>
I don't think so...
What would be the test to see if the current page has an attachment using IF.
--
DanielAjoy - 2012-01-31
See
QuerySearch
--
PeterThoeny - 2012-01-31
thanks for the pointer.
--
DanielAjoy - 2012-01-31
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.