You are here: Foswiki>Tasks Web>Item12854 (27 Apr 2014, VickiBrown)Edit Attach

Item12854: Incompatibility between IF Statements and Comment templates

pencil
Priority: Normal
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: CommentPlugin, IFStatements
Branches:
Reported By: VickiBrown
Waiting For:
Last Change By: VickiBrown
I defined a CommentPlugin template with

%TMPL:DEF{OUTPUT:guestbook}%
%POS:BEFORE% 
%URLPARAM{"guestbook_content"}%

 -- %URLPARAM{"guestbook_name"}%  (%WIKINAME%)   %DATE%
---
%TMPL:END% 

When used "normally", e.g.
  
%COMMENT{type="guestbook" target="%INCLUDINGTOPIC%"}%

it works as expected, i.e. the comment text is placed BEFORE the anchor (the comment field box).

However, if called conditionally, as
  %IF{"'%TOPIC%' allows 'change'" then="$percntCOMMENT{type=\"guestbook\" target=\"%BASETOPIC%\"}$percnt" else=""}%

the comment text appears below the anchor.

Try It:

Sandbox/Item12854TestPage

(Note: the test page uses a very simple %COMMENT{type="above"}%. My guestbook template definition isn't causing the problem.)

-- VickiBrown - 11 Apr 2014

If you can try to recreate this on http://trunk.foswiki.org/ that would be helpful. The CommentPlugin had some very substantial changes made in trunk, planned for Foswiki 1.2.

-- GeorgeClark - 12 Apr 2014

Yes Vicki, that's the case and it always will be. If you don't give it any other clues as to the location, the plugin has to navigate within the raw topic text to find where to insert the comment; it does this by looking for %COMMENT% tags. In your example you don't have one, so it can't find where to insert the comment. The solution in your case is to provide some other key (such as an anchor) to identify the location.

No action.

-- CrawfordCurrie - 25 Apr 2014

Crawford - I would almost believe you except that I considered this possibility before filing the bug and tried setting the location relative to an anchor. That didn't work as expected either.

So, good idea, wrong answer. (That and the fact that the %COMMENT% actually is present... it may not be left-adjusted to the line, but it is present.)

-- VickiBrown - 26 Apr 2014

Vicki, the important part of Crawford's answer is that the plugin has to "navigate within the raw topic text ...". In the raw topic, the string that appears is $percntCOMMENT.... When you added the anchor, was it also within the conditional text appearing as an anchor only when rendered, or was it it the raw topic "at the beginning of a line" per the formatting rules for #Anchors?

-- GeorgeClark - 27 Apr 2014

...When you added the anchor...
Yes, the anchor was in the raw topic outside of the IF, etc etc...

However, I cannot reproduce this on foswiki.org.

... Hmmmm... I've reproduced the issue using an anchor on my site but I think the issue also relates to INCLUDES. If I can get a minimal reproducible test case, I'll re-open. Or not. It's a complex app and I do have a workaround.

-- VickiBrown - 27 Apr 2014

ItemTemplate edit

Summary Incompatibility between IF Statements and Comment templates
ReportedBy VickiBrown
Codebase 1.1.9
SVN Range
AppliesTo Extension
Component CommentPlugin, IFStatements
Priority Normal
CurrentState Closed
WaitingFor
Checkins
TargetRelease n/a
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
Release01x01Checkins
Topic revision: r6 - 27 Apr 2014, VickiBrown
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