NOTE: If you are a developer, please use a private wiki based on foswiki/trunk on a daily base ...or use trunk.foswiki.org to view this page for some minimal testing.
Use Item9693 for docu changes for 1.2 and 2.0.

Item11704: Document use of %BR% to create linebreaks in FormattedSearch results

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Low Closed Engine Documentation  
Hi,

In System/VarSEARCH say that default separator in formatted search is "$n". But when I define format parameter, this is not true.

These is the search expression and the generated HTML:

%SEARCH{ search="name ~ '*'" type="query" limit="10" format="$topic" }%

<a href="/Sandbox/CommentPluginExampleComments">CommentPluginExampleComments</a>
<a href="/Sandbox/CommentPluginExamples">CommentPluginExamples</a>
<a href="/Sandbox/CommentPluginTemplateExample">CommentPluginTemplateExample</a>
<a href="/Sandbox/CompareRevisionsAddOnDemoTopic">CompareRevisionsAddOnDemoTopic</a>
<a href="/Sandbox/ImagePluginTest">ImagePluginTest</a>
<a href="/Sandbox/PluginTestEmptyPlugin">PluginTestEmptyPlugin</a>
<a href="/Sandbox/RedirectPluginDestination">RedirectPluginDestination</a>
<a href="/Sandbox/RedirectPluginTest">RedirectPluginTest</a>
<a href="/Sandbox/SaveIt">SaveIt</a>
<a href="/Sandbox/TableEspinharas">TableEspinharas</a>

%SEARCH{ search="name ~ '*'" type="query" limit="10" separator="$n" format="$topic" }%

<a href="/Sandbox/CommentPluginExampleComments">CommentPluginExampleComments</a>
<a href="/Sandbox/CommentPluginExamples">CommentPluginExamples</a>
<a href="/Sandbox/CommentPluginTemplateExample">CommentPluginTemplateExample</a>
<a href="/Sandbox/CompareRevisionsAddOnDemoTopic">CompareRevisionsAddOnDemoTopic</a>
<a href="/Sandbox/ImagePluginTest">ImagePluginTest</a>
<a href="/Sandbox/PluginTestEmptyPlugin">PluginTestEmptyPlugin</a>
<a href="/Sandbox/RedirectPluginDestination">RedirectPluginDestination</a>
<a href="/Sandbox/RedirectPluginTest">RedirectPluginTest</a>
<a href="/Sandbox/SaveIt">SaveIt</a>
<a href="/Sandbox/TableEspinharas">TableEspinharas</a>

%SEARCH{ search="name ~ '*'" type="query" limit="10" format="$topic$n" }%

<a href="/Sandbox/CommentPluginExampleComments">CommentPluginExampleComments</a>
<p></p>
<a href="/Sandbox/CommentPluginExamples">CommentPluginExamples</a>
<p></p>
<a href="/Sandbox/CommentPluginTemplateExample">CommentPluginTemplateExample</a>
<p></p>
<a href="/Sandbox/CompareRevisionsAddOnDemoTopic">CompareRevisionsAddOnDemoTopic</a>
<p></p>
<a href="/Sandbox/ImagePluginTest">ImagePluginTest</a>
<p></p>
<a href="/Sandbox/PluginTestEmptyPlugin">PluginTestEmptyPlugin</a>
<p></p>
<a href="/Sandbox/RedirectPluginDestination">RedirectPluginDestination</a>
<p></p>
<a href="/Sandbox/RedirectPluginTest">RedirectPluginTest</a>
<p></p>
<a href="/Sandbox/SaveIt">SaveIt</a>
<p></p>
<a href="/Sandbox/TableEspinharas">TableEspinharas</a>
<p></p>
<div class="foswikiSearchResultCount">Number of topics: <span>10</span></div>
<p></p>

The last is the only that generate the expected result, but I think <p></p> strange.

-- RogerioBastos - 29 Mar 2012

Add separator="%BR%" circumvent the problem.

-- RogerioBastos - 29 Mar 2012

This was discussed in IRC and CrawfordCurrie had the answer ... now obvious once he explained it. In examples 1 and 2, the $n is indeed emitted by the SEARCH, as the results each are on a separate line in the HTML source. However it is rendered as a wrapped list because single newlines in Foswiki are not "breaking" and the browser wraps the lines together for display.

The 3rd example requests a "new paragraph" in Foswiki TML markup - two consecutive newlines, leaving a blank line. Foswiki Render currently creates paragraphs by creating an empty <p></p> paragraph. This is reported in task Item11316.

-- GeorgeClark - 29 Mar 2012

Updating the FormatTokens document to include:
$n or $n() New line. Use $n() if followed by alphanumeric character, e.g. write Foo$n()Bar instead of Foo$nBar
TIP Most macros accept parameter strings which are split over multiple lines. This is usually more readable than using $n tokens. If you are familiar with sectional includes, you might also consider nested sectional includes to hold the newline content outside of the parameter string entirely.
TIP Note that newline is not a line break. The browser will wrap the lines together. If you require a line break, displaying the results on two lines, use %BR%. Or use two consecutive newlines to create a TML "Paragraph".

-- GeorgeClark - 29 Mar 2012
 

ItemTemplate edit

Summary Document use of %BR% to create linebreaks in FormattedSearch results
ReportedBy RogerioBastos
Codebase 1.1.5 RC1, 1.1.4, 1.1.0, trunk
SVN Range
AppliesTo Engine
Component Documentation
Priority Low
CurrentState Closed
WaitingFor
Checkins Foswikirev:14502 Foswikirev:14504
TargetRelease patch
ReleasedIn 1.1.5
CheckinsOnBranches Release01x01 trunk
trunkCheckins Foswikirev:14504
Release01x01Checkins Foswikirev:14502
Topic revision: r8 - 11 Apr 2012, GeorgeClark
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons LicenseGet Foswiki at sourceforge.net. Fast, secure and Free Open Source software downloads