Do I really have to hard-code a formatted search to suit a given form and its fields?

Not necessarily.

Given a web, and set of topics with a particular form attached you may simply write the following:

%INCLUDE{"%TOPIC%" section="prettyprint" form="BasicForm" inweb="%WEB%" limit="10"}%

Result:
Searched: form.name='BasicForm'
Topic TopicTitle TopicClassification TopicSummary Extension InterestedParties RelatedTopics
AcronymDefinitionsPlugin   ExtensionHub        
ActionTrackerPlugin   ExtensionHub      
AdminTopic GatewayTopic    
ApacheConfigGenerator   AdminTopic Custom Apache config file generator      
AvatarPlugin   ExtensionHub        
CommercialSupport        
ConsultantServices   AdminTopic        
ConsultantType AdminTopic      
CpanContrib   ExtensionHub        
DBIQueryPlugin   ExtensionHub   DBIQueryPlugin    
Number of topics: 10

Solution

%STARTSECTION{"prettyprint"}%%SEARCH{
     "form.name='%form%'"
     type="query"
     web="%inweb%"
     limit="%limit%"
     header="%SEARCH{
         "form.name='%form%'"
         type="query"
         web="%inweb%"
         nonoise="on"
         limit="1"
         format="   | *Topic* | $percentINCLUDE{\"%TOPIC%\" section=\"header\" webtopic=\"$web.$topic\"}$percent |"
     }%"
     format="   | [[$web.$topic][$topic]] | $percentINCLUDE{\"%TOPIC%\" section=\"row\" webtopic=\"$web.$topic\"}$percent |"
}%%ENDSECTION{"prettyprint"}%%STARTSECTION{"row"}%%FORMAT{
    "%QUERY{"'%webtopic%'/fields[NOT lc(attr)=~'h'].name"}%"
    type="string"
    format="$percentQUERY{\"'%webtopic%'/$item\"}$percent"
    separator=" | "
}%%ENDSECTION{"row"}%%STARTSECTION{"header"}%%FORMAT{
    "%QUERY{"'%webtopic%'/fields[NOT lc(attr)=~'h'].name"}%"
    type="string"
    format=" *$item* "
    separator=" | "
}%%ENDSECTION{"header"}%

Caveats

The solution assumes every topic which matches the query uses the same form definition; and that each topic will have the same number of fields (this won't be the case if you've grown your formfield definition over time: some topics will have fewer fields than others, which will break the table).

-- PaulHarvey - 15 Jan 2011

Solution 2: FlexFormPlugin

Depends on FlexFormPlugin

      * Set form = YourForm
      * Set inweb = %WEB%
      * Set limit =100

%STARTSECTION{"prettyprint2"}%%SEARCH{
     "form.name='%form%'"
     type="query"
     web="%inweb%"
     limit="%limit%"
     header="| *Topic* | %RENDERFORDISPLAY{
       form="%form%"
       format="*$name*"
       separator=" | "
     }% |"
     format="| [[$web.$topic][$topic]] | %RENDERFORDISPLAY{
       form="%form%"
       format="$formfield($name)"
       separator=" | "
     }% |"
}%%ENDSECTION{"prettyprint2"}%

This solution will render the formfields as defined in the dataform.

-- PaulHarvey - 08 Aug 2011

Support.FAQForm edit

TopicClassification FrequentlyAskedQuestion
Subject Extension, Search
Topic Summary A generic "pretty print" recipe for displaying all the formfields on a set of topics.
Extension FlexFormPlugin
Interested Parties
Related Topics WriteAQueryCookbook, Faq56
Topic revision: r4 - 27 Dec 2011, ArthurClemens - This page was cached on 04 Jun 2017 - 13:08.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License