Tags:
create new tag
view all tags

SID-01604: Including topics that utilize form data

Status: Answered Answered TWiki version: 5.0.2 Perl version:
Category: CategoryApplications Server OS: Last update: 13 years ago

I'm building a TWiki application that utilizes several forms, templates, and formatted searches. One part of this application creates topics with an attached form and subsequently uses the form data to populate a command for copying and pasting into another system. The command is lengthy and fairly complex (thus the desire for automation), and I got it working by including it in the topic template. However, after the third time fixing a grammar problem in this statement (and therefore having to manually fix the command in all of the previously created topics), I decided that I should define the grammar in its own topic and include it in the template. This allows me to make corrections in a single place and update all of the previously created topics as well as the future ones.

At this point things started to get interesting as the grammar topic does not have the form, but the individual topics do. I was able to get it working by using:

%FORMFIELD{"Name" topic="%INCLUDINGTOPIC%"}%

However, now I'm creating a roll-up topic that uses search to include the command section from the various command topics. My search results return the commands, but they lack any of the form content - presumably due to my use of INCLUDINGTOPIC.

So in a simplified form I have C -includes-> B(with form data) -includes-> A

How can I take the generic grammar from A, populate it with values from the form attached to B, and include the result in C?

-- JoshuaTharp - 2012-12-06

Discussion and Answer

Eureka!

With a little more experimentation, I think I have it figured out. Let me document what I've found for future reference.

Topic A

This is the topic with the grammar template. It has a number of lines, but the following two are typical.

%FORMFIELD{"Name" topic="%INCLUDINGTOPIC%"}%
%CALCULATE{$IF($NOT($EMPTY(%FORMFIELD{"Description" topic="%INCLUDINGTOPIC%"}%)), DESC '%FORMFIELD{"Description" topic="%INCLUDINGTOPIC%"}%')}%

The two key takeaways here:

  • Use the topic parameter specifing INCLUDINGTOPIC
  • Use the SpreadSheetPlugin instead of VarIF - they do not behave similarly and while I could specify $formfield with VarIF, I could not figure out how to also specify the topic parameter
QUESTION? Is there an easier way to specify "If a form field has a value" than the $IF($NOT($EMPTY(formfield))) construct above?

Topic B

This is actually a template and a number of instances - one of these per command. Each has a form attached to it with several required and several optional values. As you can see from line 2 of Topic A if a form field is not provided, then I have to omit a portion of the grammar. Included in each instance Topic B is a section with the command included.

%STARTSECTION{"command"}%
<pre>
%INCLUDE{"CommandGrammar"}%
</pre>
%ENDSECTION{"command"}%

Topic C

This is my roll-up topic. It has a search that grabs all of the generated commands and puts them on one page for easy reference.

%SEARCH{
  search="form[name='CommandForm']"
  type="query"
  nonoise="on"
  format="$percntINCLUDE{\"$topic\" section=\"command\"}$percnt"}%

-- JoshuaTharp - 2012-12-06

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Answered
Title Including topics that utilize form data
SupportCategory CategoryApplications
TWiki version 5.0.2
Server OS

Web server

Perl version

Browser & version

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2012-12-10 - JoshuaTharp
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.