This question about Topic Markup Language and applications: Answered

Default values in Data Forms: macro expansion only once

I would like to have default values in a data form constructed by macro expansion. That's of course no problem, but how do I achieve that the macro expands only once i.e. the moment I add the form to the topic?

My application for this is, that when I search the topics I get the macro expanded in the context of the topic where my search lives, which renders the wrong text. Instead I would like to have to have the text rendered as if the macro were expanded within the context of the found topic. %BASETOPIC% doesn't help, so it would be nice, to have the macro expanded only once and save only the expanded value into the form field.


Well, there are some options for this. If you truly want to save some text after its macros have been expanded,FrequentlyAskedQuestions as the value of a formfield, some things you could try...

-- PaulHarvey - 05 Jul 2011

My application is a kind of support database for a customer. I have a MachineForm describing the technical data of a server machine in the customer's web cluster. One of the formfields is the FQDN of the machine. The topics each one describing one server and having attached the MachineForm are named the same as the machine itself. Now it's easy to get a default value for the FQDN formfield by using $percntCALC{$dollarLOWER($percntTOPIC$percnt)}$percnt.examplecustomer.com as value in the form definition. Now there is another topic named MachineList containing a search which ouputs this formfield. Now %TOPIC% is expanded in the context of MachineList resulting in "machinelist.examplecustomer.com" instead of the wanted "machinename.examplecustomer.com". That's why I'm looking for a possibility to construct a default value for a formfield using macro expansion but saving only the expanded value. Hope this clears things up smile

-- ValentinMayer - 05 Jul 2011

Well, there are some possibilities.

But the easiest of all, is just to modify your SEARCH format so that it lower-case's the formfield value on each hit, something like:
Error: no such plugin chili
%SEARCH{
  "form.name='QuestionForm'"
  type="query"
  web="%WEB%"
  pager="on"
  pagesize="10"
  nonoise="on"
  format="   * [[$web.$topic]] - $formfield(Status) vs $percntQUERY{lc('$web.$topic'/Status)}$percnt"
}%

Test:
Page 1 of 108 Next >

-- PaulHarvey - 06 Jul 2011
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