SID-02031: Display form field of a referenced topic in formatted search
| Status: |
Answered |
TWiki version: |
6.0.0 |
Perl version: |
|
| Category: |
CategorySearch |
Server OS: |
Ubuntu Linux 14.01 |
Last update: |
10 years ago |
It is probably simple but I did not find the solution after one day of searching
docs and support pages and some trials and errors ...
I would like to maintain a list of conference paper contributions and
see the deadline for abstract submission approaching. There may be
more submissions to a single conference, so that the conference date
can be stored in one Form called
ConferenceForm
containing the field "deadline_abstract"
| *Name* | *Type* | *Size* | *Values* | *Tooltip message* | *Attributes* |
| deadline_abstract | date | 60 | | deadline for abstract submission | |
and the object / form containing the paper data can refer to the conference
using the select formfield called conference, i.e.:
ConferencePaperForm
| *Name* | *Type* | *Size* | *Values* | *Tooltip message* | *Attributes* |
| paper_title | text | 60 | | title of the paper | |
| conference | select+values | 1 | ---, %SEARCH{ "form.name='ConferenceForm'" type="query" excludetopic="*Template" nonoise="on" format="$topic" separator=", " }% | conference topic in the coordination web | |
Now the question: how can I display a table of currently processed conference submissions
listing the abstract deadline next to the paper title. I did not find a simple way to retrieve
the formfield within the format specification of the variable.
| *Paper title* | *Conference* | *Abstract deadline* |
%SEARCH{ "form.name='ConferencePaperForm'"
type="query"
sort="modified"
excludetopic="*Template"
nonoise="on"
format="|$formfield(paper_title) | $formfield(conference)| How to access a field of conference here? |"}%
I also considered to defined a hidden field of ConferencePaperForm that would retrieve the value of the deadline from the ConferenceForm, but no success. I would be really happy for any hint.
Many thanks.
--
Rostislav Chudoba - 2015-03-05
Discussion and Answer
Use the
VarFORMFIELD variable to pull a form field value from another topic. When you use it in a
FormattedSearch you need to delay the rendering so that it runs once per search hit, otherwise it will fire just once before the search. Delay by escaping the %-sign with
$percnt. Untested example:
format="|$formfield(paper_title) | $formfield(conference) | $percntFORMFIELD{ \"deadline_abstract\" topic=\"$formfield(conference)\" }$percnt |"
Details in aforementioned links.
--
Peter Thoeny - 2015-03-05
If you are concerned about performance you could first do a search on conferences, store the deadline in a
SpreadSheetPlugin hash, and use that hash in the paper title search. Example how to retrieve a hash called
deadlines:
format="|$formfield(paper_title) | $formfield(conference) | $percntCALCULATE{$GETHASH(deadlines, $formfield(conference))}$percnt |"
Detail in blog
Advanced TWiki Spreadsheet Formulas: Power and Flexibility - Not For Grandma.
--
Peter Thoeny - 2015-03-05
You saved my day, Peter.!
The first version using
VarFORMFIELD is actually clear and I was already trying this way. There are some examples elsewhere presenting the nested search which is similar. . I was not careful enough about the escaping within the format parameter.. Thank you for the other hints to the other possible solutions. I will need them.
--
Rostislav Chudoba - 2015-03-05
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.