This question about Topic Markup Language and applications: Answered

Exclude part of topic in EditTemplate

Hey folks,

I want to hide the TML of the ActionTrackerPlugin that gets inserted with the CommentPlugin. This is just to get you some background.

The question basically is how can I exclude or hide a part of a topic? I created my own EditTemplate and figured out that this part is responsible for the editorbox and the text that gets in there.

%{ if an editor plugin sets EDITOR_MESSAGE, then use it }% %TMPL:DEF{"textarea"}%%TMPL:END%

My first approach was to replace the %TEXT% variable with a simple %INCLUDE{"!Question640"}% and add a %STARTINCLUDE% to my topic having the text I want to get excluded above that. But by doing this on the save the information above the %STARTINCLUDE% gets not only hidden but lost! So, how can I hide then a part of topic? Where is this %TEXT% variable defined?

Coming back to the background. With CommentPlugin I want to post an action to a location in the topic that normally is not seen by every user because I create indivual views with actionsearch and dont want the people to get confused by the TML code in the normal topic text. Any help or hint is as always highly appreciated.

You can use EditChapterPlugin for the editing of page 'sections'. Alternatively, what I have done is add a parameter to the default list of action parameters called 'reltopic'. Then I have all actions save to a topic called WebActions with the reltopic parameter set to the topic the action is related to. In your ACTIONSEARCH in your view template you just need to stipulate the extra condition that 'reltopic=%BASETOPIC%' . Or, instead of having a single topic per web such as WebActions, you could have a special Actions topic created per topic, e.g. '%BASETOPIC%Actions' (the save script as called by the CommentPlugin would take care of the topic creation for you).

-- DavidPatterson - 07 Sep 2010

Thanks for your answer. But that wasn't exactly what I was looking for. Actually I already found that work around with the '%<nop>BASETOPIC%Actions. Unfortunately the link provided by the actionsearch will still point to the '%<nop>BASETOPIC%Actions but should point to the original '%<nop>BASETOPIC%. So that this link basically gets unpracticable as it stops pointing to the topic where the action originally belongs to!

-- PaulHahler - 07 Sep 2010

OK. I assume you're talking about the edit link which launches a separate window to allow editing of the action: you edit, click save, the action details update and the page reloads in the launched window to the Actions topic whilst the original page remains unchanged. Yeah, that's a long standing issue with the ATP and needs addressing with some AJAX goodness.

In the meantime, if you don't want to live with that you can continue with what you've started with and use %STARTSECTION{}% and %ENDSECTION{}% to divide up your topic. Use something like the CommentPlugin's target parameter to add your actions to the %STARTSECTION{name="action"}% section and then do a raw include of that section into a hidden input of your edit form whilst you do a raw include of the 'name="text"' section into the textarea of your edit form and then use some javascript in the form's onsubmit to create the new topic text before submitting to the server.

I don't think you'll find %TEXT% defined anywhere in the doco. This is a variable used in the templates which the scripts such as view and edit replace with the topic text.

-- DavidPatterson - 08 Sep 2010

Quote: "and then do a raw include of that section into a hidden input of your edit form whilst you do a raw include of the 'name="text"' section into the textarea of your edit form and then use some javascript in the form's onsubmit to create the new topic text before submitting to the server."

Exactly! This is what I was asking at the very beginning. How can I do that?! I have absolutely no idea who to hide a certain section from VIEW and EDIT and still get it saved back as his raw content into the topic! I know I have to make changes to the edit TMPL but my results is what you see above. If I do an include instead of using the simple %TEXT% it does not include my hidden part. How do I send that information without letting the user actually see the part with the actions?

-- PaulHahler - 14 Sep 2010

Very rough untested pseudo-type HTML and javascript, your edit form should end up having the following main elements:

<form name="main" action="%SCRIPTURLPATH{"save"}%/%WEB%/%TOPIC%" method="post" onsubmit="return buildTopic(this,event)">
<input type="hidden" name="topicactions" value="%ENCODE{"%INCLUDE{"%BASETOPIC%" section="actions" literal="on"}%"}%" />
<textarea class="foswikiTextarea foswikiEditboxStyleProportional foswikiWysiwygEdit" id="topic" name="topictext" rows="%EDITBOXHEIGHT%" cols="%EDITBOXWIDTH%" style='%EDITBOXSTYLE%'> %INCLUDE{"%BASETOPIC%" section="text" literal="on"}% </textarea>
<input type="hidden" name="text" />
<script type="text/javascript">
function buildTopic(form,event){
    if (!validateMandatoryFields(event)) return false;
    var startactions = "%ENCODE{"%STARTSECTION{name="actions"}%"}%\n";
    var endactions = "%ENCODE{"%ENDSECTION{name="actions"}%"}%\n";
    var starttext = "%ENCODE{"%STARTSECTION{name="text"}%"}%\n";
    var endtext = "%ENCODE{"%ENDSECTION{name="text"}%"}%\n";
    form.text.value = startactions + form.topicactions.value + endactions + starttext + form.topictext.value + endtext;

The ENCODEs might have to be of type="html" (I always get it wrong first time).

your VIEW_TEMPLATE then has %INCLUDE{"%BASETOPIC%" section="text"}% in place of %TEXT% in the content TMPL

-- DavidPatterson - 16 Sep 2010

QuestionForm edit

Subject Topic Markup Language and applications
Extension ActionTrackerPlugin
Version Foswiki 1.0.9
Status Answered
Related Topics
Topic revision: r7 - 13 Feb 2012, CrawfordCurrie
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