You are here: Foswiki>Tasks Web>Item12868 (05 Jul 2015, GeorgeClark)Edit Attach

Item12868: SEARCH newline parameter does not apply to ItemTemplatefield content

pencil
Priority: Urgent
Current State: Closed
Released In: 2.0.0
Target Release: major
Applies To: Engine
Component: SEARCH
Branches: master
Reported By: DavidAllen
Waiting For:
Last Change By: GeorgeClark
I'm porting from TWiki and have a SEARCH that I am formatting into a table, the SEARCH queries a form where one of the fields contains a bulleted list. I need this bulleted list to render correctly within the containing table. This is challenging in Foswiki for two reasons; first, new lines returned from a $formfield are always transformed to <br />, which breaks rendering of the the bulleted list, and second, even if $formfield produced raw new lines those would break the render of the TML table.

related:

I solved the TML table rendering issue by installing TWiki's RecursiveRenderPlugin and using its <render> tag; the installation was unfortunately challenging since it has not been ported to Foswiki yet.

It is then possible to work-around the newline/$formfield issue by embedding a QUERY for the raw value into the SEARCH format:

%SEARCH{
   "Role$"
   scope="topic"
   type="regex"
   nonoise="on"
   header="| *Name* | *Purpose* | *Energizers* |"
   format="| [[$topic][$formfield(Name)]] | <render>$percentQUERY{\"'$topic'/Purpose\"}$percent</render> | <render>$percentQUERY{\"'$topic'/Energizers\"}$percent</render> |"
}%

I find this nested QUERY unnecessarily complex and would much prefer for the newline parameter to apply to $formfield so I could do this:

%SEARCH{
   "Role$"
   scope="topic"
   type="regex"
   nonoise="on"
   newline="$n"
   header="| *Name* | *Purpose* | *Energizers* |"
   format="| [[$topic][$formfield(Name)]] | <render>$formfield(Purpose)</render> | <render>$formfield(Energizers)</render> |"
}%

I'm attaching my suggested patch for this issue, created on http://svn.foswiki.org/tags/FoswikiRelease01x01x09. This patch updates SEARCH.pm to pass the value of the newline parameter along to Foswiki::Meta::renderFormFieldForDisplay as an attribute. During execution Foswiki::Render::protectFormFieldValue is called, and it already has code to complete the replacement. If no newline parameter is provided, then the current default behavior is maintained--new lines are replaced with <br / >.

Also included in the patch are the related changes to documentation, and uncommenting CrawfordCurrie's unit test for this feature.

This patch works on my 1.1.9 install. I don't have a functioning test environment so I have not verified the unit test.

-- DavidAllen - 26 Apr 2014

Marking this as urgent so that it gets considered for 1.2 in the tasks review.

-- GeorgeClark - 29 May 2014

Good patch. Thanks DavidAllen.

-- CrawfordCurrie - 05 Nov 2014

 

ItemTemplate edit

Summary SEARCH newline parameter does not apply to $formfield content
ReportedBy DavidAllen
Codebase 1.1.9
SVN Range
AppliesTo Engine
Component SEARCH
Priority Urgent
CurrentState Closed
WaitingFor
Checkins distro:d19b93d610a4
TargetRelease major
ReleasedIn 2.0.0
CheckinsOnBranches master
trunkCheckins
masterCheckins distro:d19b93d610a4
ItemBranchCheckins
Release01x01Checkins
I Attachment Action Size Date Who Comment
Suggested-Patch-For-Item12868.diffdiff Suggested-Patch-For-Item12868.diff manage 7 K 26 Apr 2014 - 03:33 DavidAllen Suggest patch for this item.
Topic revision: r8 - 05 Jul 2015, GeorgeClark
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