Question
I have created a form called ServerInfoForm. In this form I include information like Hostname, IP Address, Memory, etc.
Every server has it's own Topic page with this same form.
Is it possible to query the data in all forms to get, for example, a list of the IP addresses on each server in a simple 3 columned table? The columns being:
| Topic Name |
Hostname |
IP Address |
Environment
--
RyanBauerle - 17 Sep 2007
Answer
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.
That would sound like a perfect job for
FormQueryPlugin! You should read the
FormQueryPluginTutorial first, since the plugin topic is
very technical. I dare to mark your question as "answered", but if you need further assistance, don't hesitate to re-open it.
--
HaraldJoerg - 18 Sep 2007
Even without the FormQueryPlugin, this looks like a simple
FormattedSearch. See all
VarSEARCH options.
If you want to go fancy, the
TWikiInstallation directory is a sample application that has a SEARCH with a filter.
--
PeterThoeny - 18 Sep 2007
Thanks. I was able to install the plugin from the configure interface and I read through the turorial, but I'm still having trouble with the syntax. Do you think you can give me another push in the right direction?
Thanks
--
RyanBauerle - 18 Sep 2007
Peter and Harald, thanks for your responses.
Before Harald gave the idea of the plugin, I had searched through the topics that Peter mentioned. But in both cases I am having trouble getting the syntax right.
Any chance you can provide a little more help?
--
RyanBauerle - 18 Sep 2007
Sorry guys...now I feel dumb because it is so simple now that I got it to work the first time. Thanks for your help!
Here is what I did:
| *Topic:* | *HostName:* | *IpAddress1:* |
%SEARCH{ "[H]ostName.*?value=\"*\"" scope="text" regex="on" nosearch="on" nototal="on"
format="| [[$topic]] | $formfield(HostName) | $formfield(IpAddress1) |" }%
Thanks!
--
RyanBauerle - 18 Sep 2007
No need to feel dumb. Though I'm using TWiki for some years now, it almost always takes me some experiments to get the syntax right.
I should feel silly for recommending a solution which is nothing but over-engineering for your use case. Glad you figured out the simple solution
--
HaraldJoerg - 18 Sep 2007
I was able to use the modified code provided by Ryan to retrieve fields from my forms; however, I have the following 2 questions:
- The search also returned record for the topic where the form is defined. How can this be prevented?
- What exactly does the "[H]ostName.*?value=\"*\"" regex mean? What is the syntax for value= ?
Thank you,
--
AndyAndrews - 31 Dec 2007
Question 1:
Use the
excludetopic="" parameter. See details in
VarSEARCH.
Question 2:
The regex seems to be incorrect. I'd search for the form name or the field, one of:
-
"META\:FORM.*name=\"FooBarForm\""
-
"META\:FIELD.*name=\"HostName\""
This searches the raw form data. Example format:
%META:FORM{name="FooBarForm"}%
%META:FIELD{name="HostName" attributes="" title="HostName" value="qwerty"}%
--
PeterThoeny - 31 Dec 2007