• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Given every comment of a threaded comment system is stored as a separate topic you could be tempted to rendered things using a call like

%<nop>INCLUDE{"RenderSubComments" NAME="TestTopic"}%

where RenderSubComments is defined as

%STARTINCLUDE%
%<nop>SEARCH{"META:FIELD{name=\"Ref\".*value=\"%NAME%\""
        type="regex" nonoise="on" order="created" reverse="on"
        format="
          <div class=\"subComments\">
             $topic$percntINCLUDE{\"RenderSubComments\" NAME=\"$topic\"}$percnt
          </div>
        "
 }%
%STOPINCLUDE%

and comments are linked to each other by a Ref formfield entry.

Each call to RenderSubComment will be done with a different NAME parameter, thus this construction will always terminate.

Alas, this desired behaviour is not possible as TWiki::_INCLUDE only checks for web.topic being included already. The attached patch adds the parameters and its values to the stack entry of already included topics, so that we only get an "already included" warning if there really is an infinite loop.


Btw. why do I have to nop the INCLUDE and SEARCH in the above example?


Here's the patch in action rendering blog comments recursively.

MD


CCRB

  • Approve, subject to parameters being sorted before they are stacked. -- CrawfordCurrie - 27 Sep 2005
  • Approve as long as Crawford's concern is addressed. Seems like logical necessity to make feature work as expected. -- LB
  • Approve. this actually seems more like a bugfix. -- WN

i applied the following (adjusted patch) to SVN:6725

Index: TWiki.pm
===================================================================
--- TWiki.pm    (revision 6719)
+++ TWiki.pm    (working copy)
@@ -2433,7 +2433,12 @@
         } # else fail silently
         return '';
     }
+
+    # compute include key
     $path = $incweb.'.'.$inctopic;
+    foreach my $k ( sort keys %$params ) {
+       $path .= ":$k=$params->{$k}";
+    }

     # prevent recursive includes. Note that the inclusion of a topic into
     # itself is not blocked; however subsequent attempts to include the

WN


MD, please check this patch and close if appropriate. WN


MD is very happy with recusive INCLUDESs and even feels save again since Item666 is done.


ItemTemplate
Summary can't INCLUDE topic recursively with different parameters
ReportedBy MichaelDaum
AppliesTo Engine
Priority Enhancement
CurrentState Closed
WaitingFor

Checkins 6725
Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatdiff TWiki_pm.diff r0 manage 0.5 K 2005-09-26 - 14:16 UnknownUser  
Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r8 - 2005-10-14 - MichaelDaum
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback