This question about Topic Markup Language and applications: Answered

Combination of Include and Searchfunction

Hello,

I have a search function that ends in a selectmode to choose a topic and the actionbutton called "Include topic" Right now it looks like this:
<form>
<select name="topic">
<option value="%TOPIC%">Select...</option>
%SEARCH{
"StandardOperatingProcedure"
scope="topic"
excludetopic="SoPTemplate"
format="<option value='$web.$topic'>$topic</option>"
separator=" "
}%
</select>
<input type="submit" value="Include topic" />
</form>

I have two problems.

Problem one: When pressing the actionbutton "Include topic", the selected Topicpage opens, but I want that after pressing the button, the selected Topic is entered on the Page.

Problem two: I don´t want, that only the foswiki name is shown on the page after pressing the button, I want that the content of the foswikiword is shown on the page, like it happens after using the INCLUDE-MACRO. So I thought I can combine the INCLUDE- and SEARCH-MACRO like this:
%INCLUDE{ 
    "%SEARCH{ 
    "..."
    }%" 
}%

But I get the Errormessage:

WarningCan't INCLUDE '
 <input type="submit', path is empty or contains illegal characters.

I am glad if you can help me.

Thank you in advance

-- AbhilashaKerkmann - 22 Apr 2020

I'm not 100% sure I'm understanding what you're after but let me give it a try. First, the issue with your form is that it does not include an action combined with using the "topic" element name for selecting the target topic. The url parameter "topic" usually indicates the topic you want to display. In the second case, if you are wanting to INCLUDE the selected target topic in the base topic, you don't need to use the SEARCH macro inside your INCLUDE.

So here's the solution I think you're after.
<form action='%SCRIPTURL{view}%/%WEB%/%TOPIC%'>
<select name="target">
<option value="">Select...</option>
%SEARCH{"StandardOperatingProcedure"
   scope="topic"
   excludetopic="SoPTemplate"
   nonoise="on"
   format="<option value='$web.$topic' $percntIF{\"$'target'='$web.$topic'\" then=\"selected\"}$percnt >$topic</option>"
   separator=" "
}%
</select>
<input type="submit" value="Include topic" />
</form>

%IF{"defined target and $'target'!=''"
   then="$percntINCLUDE{\"%URLPARAM{"target"}%\"}$percnt"
}%

Give this a try and please let me know if I'm off base or if you have further questions. Good luck!

-- Main.LynnwoodBrown - 22 Apr 2020

Dear Lynnwood, this is amazing, you helped me a lot, thank you very much. There are two new problems left. -I realised, that the topic I selected is not remembered. The moment I visit the Page again, the selected included topic is disappeared. -And I like to use the comment to include several topics on the page. But the moment I select another topic, the old topic will be overwritten. I am happy if you also have an answer for this.

-- AbhilashaKerkmann - 24 Apr 2020

Ah, I see what you're after now. You are really wanting to use CommentPlugin to post an INCLUDE into your base topic so that the selected topic is permanently displayed in the base topic. To accomplish this, you'll need to define a custom comment template.

To get you started, you comment definition might look something like this: (Note: I didn't test this out but i think it should work.)
%TMPL:DEF{PROMPT:includetopic}%<select name="target" class="foswikiInputField">
<option value="">Select...</option>
%SEARCH{"StandardOperatingProcedure"
   scope="topic"
   excludetopic="SoPTemplate"
   nonoise="on"
   format="<option value='$web.$topic' >$topic</option>"
   separator=" "
}%
</select><input %DISABLED% type="submit" value="%button|Add item%" class="foswikiButton" />%TMPL:END%

%TMPL:DEF{OUTPUT:includetopic}%
%INCLUDE{"%URLPARAM{"target"}%"}%%POS:AFTER%
%TMPL:END%

And then you'd put this into the topic where you want to display the INCLUDED topics:
%COMMENT{type="includetopic"}%
You should read-up on the details on creating a custom comment template so as to understand the correct place to put your template defintion and see other options for controlling where your comment is placed in the base topic.

-- LynnwoodBrown - 24 Apr 2020

Dear Lynnwood,
This is exactly what I wanted.
Thank you very much!

-- AbhilashaKerkmann - 27 Apr 2020

 

QuestionForm edit

Subject Topic Markup Language and applications
Extension
Version Foswiki 1.1.4
Status Answered
Related Topics
Topic revision: r7 - 27 Apr 2020, LynnwoodBrown
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy