Debian Codegraph @

htdoc/hts_selectors.html

raw
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
2 <html>
3 <head>
4 <title>
5 ht://Dig: htsearch
6 </title>
7 </head>
8 <body bgcolor="#eef7ff">
9 <h1>
10 htsearch
11 </h1>
12 <p>
13 ht://Dig Copyright &copy; 1995-2004 <a href="THANKS.html">The ht://Dig Group</a><br>
14 Please see the file <a href="COPYING">COPYING</a> for
15 license information.
16 </p>
17 <hr size="4" noshade>
18 <h2>
19 Input parameter select lists
20 </h2>
21 <p>
22 The primary interface to htsearch is through an HTML
23 <a href="hts_form.html">form</a>.
24 The input fields in this form can be defined as any type that
25 HTML allows, but some of these are best handled through HTML
26 <em>select</em> lists.
27 </p>
28 <h3>
29 <a name="predefined"></a>
30 Pre-defined template select lists
31 </h3>
32 <p>
33 In order to propagate these select lists to the search form
34 in the results template, so that the default <em>selected</em>
35 value will be the one the user last selected, htsearch defines
36 a few of these select lists as
37 <a href="hts_templates.html">template variables</a>.
38 These variables are:
39 </p>
40 <ul>
41 <li>
42 <strong>FORMAT</strong>, which selects the <b>format</b> input parameter
43 for follow-up searches, with the current value being the
44 default. The current value is taken from the <strong>format</strong>
45 input parameter, if one was provided, or from the
46 <a href="attrs.html#template_name">template_name</a>
47 attribute otherwise, and this value will also be given in
48 the <strong>SELECTED_FORMAT</strong> template variable.
49 The various parameter values, and their corresponding
50 labels for the select list, are taken from the
51 <a href="attrs.html#template_map">template_map</a>
52 attribute.
53 </li>
54 <li>
55 <strong>METHOD</strong>, which selects the <b>method</b> input parameter
56 for follow-up searches, with the current value being the
57 default. The current value is taken from the <strong>method</strong>
58 input parameter, if one was provided, or from the
59 <a href="attrs.html#match_method">match_method</a>
60 attribute otherwise, and this value will also be given in
61 the <strong>SELECTED_METHOD</strong> template variable.
62 The various parameter values, and their corresponding
63 labels for the select list, are taken from the
64 <a href="attrs.html#method_names">method_names</a>
65 attribute.
66 </li>
67 <li>
68 <strong>SORT</strong>, which selects the <b>sort</b> input parameter
69 for follow-up searches, with the current value being the
70 default. The current value is taken from the <strong>sort</strong>
71 input parameter, if one was provided, or from the
72 <a href="attrs.html#sort">sort</a>
73 attribute otherwise, and this value will also be given in
74 the <strong>SELECTED_SORT</strong> template variable.
75 The various parameter values, and their corresponding
76 labels for the select list, are taken from the
77 <a href="attrs.html#sort_names">sort_names</a>
78 attribute.
79 </li>
80 </ul>
81 <p>
82 In addition to these template variables, htsearch makes
83 use of a number of other input parameters, all of which
84 have corresponding template variables and configuration
85 attributes. It's also possible, within htsearch, to make an
86 input parameter out of any <a href="attrs.html">configuration
87 attribute</a> that's not already automatically handled by an
88 input parameter. This is accomplished by means of the
89 <a href="attrs.html#allow_in_form">allow_in_form</a> attribute.
90 The attributes listed in the allow_in_form list will be settable
91 in the search form using input parameters of the same name,
92 and will be propagated to the follow-up search form in the
93 results template using template variables of the same name
94 in upper-case.
95 </p>
96 <h3>
97 <a name="custom"></a>
98 Custom template select lists
99 </h3>
100 <p>
101 This gives you a great deal of flexibility in configuring
102 htsearch, but all of these template variables still contain
103 only the parameter value, and not a select list to choose
104 the value. In order to use any input parameters as select
105 lists, other than the three pre-defined variables above, one
106 must either statically define a select list in the results
107 template follow-up form, just as in the initial search form
108 or instruct htsearch to build one as a template variable.
109 Statically defining new select lists is easier, as you have
110 to do it for the initial search form anyway, but this has the
111 drawback that the user's selection from the initial form does
112 not appear as the default selection in the follow-up form,
113 because the default is static.
114 </p>
115 <p>
116 To overcome this drawback, you must use the
117 <a href="attrs.html#build_select_lists">build_select_lists</a>
118 configuration attribute. Its usage is a bit complicated, but
119 it's extremely flexible, allowing you do define any htsearch
120 input parameter as a select list for use in templates, provided
121 you also define the corresponding name list attribute which
122 enumerates all the choices to put in the list. It can be used
123 for existing input parameters, as well as any you define using
124 the allow_in_form attribute.
125 </p>
126 <p>
127 The entries in this list each consist of an <em>octuple</em>, a
128 set of eight strings defining the variables and how they are to
129 be used to build a select list. The attribute can contain many
130 of these octuples. The strings in the string list are merely
131 taken eight at a time. For each octuple of strings specified in
132 build_select_lists, the elements have the following meaning:
133 </p>
134 <ol>
135 <li>
136 the name of the template variable to be defined as a list,
137 optionally followed by a comma and the type of list, and
138 optional formatting codes
139 </li>
140 <li>
141 the input parameter name that the select list will set
142 </li>
143 <li>
144 the name of the user-defined attribute containing the
145 <em>name list</em>, that is the list of values and labels
146 for the select list items, much like the template_map,
147 method_name and sort_name attributes
148 </li>
149 <li>
150 the <em>tuple</em> size used in the name list above
151 </li>
152 <li>
153 the index into a name list tuple for the value
154 </li>
155 <li>
156 the index for the corresponding label to be displayed on
157 the selector
158 </li>
159 <li>
160 the configuration attribute where the default value for
161 this input parameter is defined, which may or may not be
162 the same name as the input parameter
163 </li>
164 <li>
165 the default label, if not an empty string, which will be
166 used as the label for an additional list item for the
167 current input parameter value if it doesn't match any value
168 in the given list
169 </li>
170 </ol>
171 <p>
172 The first element in an entry is actually a comma separated
173 list. The first item within this list is the name of the
174 template variable to be created. The next item, if specified,
175 is the type of select list or input list to be created in this
176 template variable. Choices are <strong>select</strong>,
177 <strong>multiple</strong>, <strong>radio</strong>,
178 and <strong>checkbox</strong>, with the default being
179 <strong>select</strong>. The word <strong>multiple</strong>
180 refers to a &lt;select multiple&gt; type of select list,
181 where more than one option can be selected. The choices
182 <strong>radio</strong> and <strong>checkbox</strong> will build
183 lists of &lt;input&gt; tags of these types, rather than a select
184 list with &lt;option&gt; tags. The optional third and fourth
185 items in this comma separated list are text or formatting tags
186 that will be prepended and appended, respectively, to each item
187 in the built list, before the &lt;option&gt; or &lt;input&gt;
188 tag and after the label for that tag. This first element is
189 parsed as a quoted string list within a quoted string list,
190 so you can embed quotes and commas within elements of this
191 inner list if you use correct quoting. See examples below.
192 </p>
193 <p>
194 The name list that you define will most commonly consist
195 of pairs of values, and therefore you'd use a tuple size of
196 2. The method_names and sort_names attributes are samples of
197 such name lists. You can give any name you'd like to the name
198 list attributes you define yourself, but you should try to
199 avoid using any of the names of <a href="attrs.html">existing
200 attributes</a>. The value and label for the pairs in lists you
201 define yourself can appear in either order, depending on the
202 index you specify for each. In the case where you'd want the
203 labels on the selector to be the same as the actual parameter
204 values used, which would make sense for lists of numbers,
205 you can use a tuple size of 1, and indexes of 1, to avoid
206 having to duplicate all the numbers in the list.
207 </p>
208 <p>
209 Any of the strings in an octuple may be quoted, and should be if
210 you want to include spaces or define an empty string. If the
211 default label, the eight element in an entry, is an empty
212 string, the select list will not have a <em>selected</em> item
213 if the current input parameter value doesn't match any value
214 in the name list. If a default label is given, an additional
215 list item will be added to the list using this label, if the
216 current input parameter value doesn't match.
217 </p>
218 <p>
219 If the seventh element, the configuration attribute name, is
220 an empty string, the default value will be taken from from
221 the input parameter, the second element, instead. This is
222 especially useful for input parameters that don't get mapped
223 to a configuration attribute, or for checkboxes or multiple
224 selects, where the separation between individual choices may
225 get lost when the input parameter is mapped to an attribute.
226 </p>
227 <p>
228 Here is an example of its usage, which illustrates different
229 tuple sizes and orders:
230 </p>
231 <pre>
232 build_select_lists: MATCH_LIST,radio matchesperpage matches_per_page_list \
233 1 1 1 matches_per_page "Previous Amount" \
234 RESTRICT_LIST,multiple restrict restrict_names 2 1 2 restrict "" \
235 FORMAT_LIST format template_map 3 2 1 template_name ""
236
237 matches_per_page_list: 1 5 10 20 100 500
238
239 restrict_names: "http://www.myschool.edu/Admin/" "Admin Web Pages" \
240 "http://www.myschool.edu/Faculty/" "Faculty Web Pages" \
241 "http://www.myschool.edu/Student/" "Student Web Pages" \
242 "" "Whole Web Site"
243 </pre>
244 <p>
245 The FORMAT_LIST example should give something equivalent to the FORMAT
246 template variable, which is already set by htsearch. It is included as
247 an additional example of how to specify the tuple size and indices of
248 values and labels in a tuple.
249 </p>
250 <p>
251 Here is an example which illustrates additional formatting tags,
252 and the quoting that may be required:
253 </p>
254 <pre>
255 build_select_lists: "RESTRICT_LIST,checkbox,'&lt;font face=\\"Arial,Helvetica\\" size=\\"+2\\"&gt;',&lt;/font&gt;&lt;br&gt;" \
256 restrict restrict_names 2 1 2 restrict ""
257 </pre>
258 <p>
259 In this example, the font tag will be inserted before each
260 checkbox input tag, and the closing font tag and line break will
261 be appended after each label that follows the input tag. Because
262 the font tag has an embeded comma, which is also the separator
263 for the list in the first element, the whole tag (i.e. the whole
264 third item in the comma separated list) is quoted, and it's
265 quoted with single quotes so as not to conflict with the double
266 quotes enclosing the whole element. Finally, to embed a double
267 quote in the font tag, it must be escaped with two backslashes -
268 the first of these is absorbed by the variable expansion phase
269 that all attribute values go through, and the second is used
270 to embed the double quote within a double quoted string.
271 </p>
272 <h3>
273 <a name="template_patterns"></a>
274 Combining the format select list with template_patterns
275 </h3>
276 <p>
277 The addition of the <a href="attrs.html#template_patterns">
278 template_patterns</a> attribute has added a new wrinkle to
279 the pre-defined select list for the <strong>format</strong> parameter.
280 If a document URL matches an entry in template_patterns, its
281 corresponding result template will override any template the
282 user selected with the format parameter. The problem stems
283 from the fact that the two were not originally intended to
284 be used together in the same htsearch configuration. When
285 configuring htsearch, you'd normally set it up to use one
286 mechanism or the other, but not a combination of the two.
287 </p>
288 <p>
289 However, the following example would allow user-selected
290 templates to work together with template_patterns:
291 </p>
292 <pre>
293 template_map: Long long ${common_dir}/long.html \
294 Short short ${common_dir}/short.html
295 template_name: long
296 template_patterns: .pdf ${common_dir}/${template_name}-pdffile.html \
297 .ps ${common_dir}/${template_name}-psfile.html \
298 .doc ${common_dir}/${template_name}-docfile.html
299 </pre>
300 <p>
301 This works because the template_name attribute gets set
302 internally in htsearch, to the user-selected value of the
303 <strong>format</strong> input parameter, before the variable expansion
304 in template_patterns takes place. As long as you stick to
305 a template file naming convention that uses the internal
306 name element of template_map (second element in a triple) as
307 part of the file name, this should work like a charm. Your
308 common directory would have to contain the template files
309 long-pdffile.html, long-psfile.html, long-docfile.html,
310 short-pdffile.html, short-psfile.html, and short-docfile.html,
311 for the example above to work, in addition to the long.html
312 and short.html files, which will be used for URLs that don't
313 match any of the patterns. Of course, these patterns can be
314 any URL parts, and not just suffixes. Be sure to also change
315 the values for format in your initial search form, search.html,
316 to use your chosen internal names.
317 </p>
318
319 <hr size="4" noshade>
320
321 Last modified: $Date: 2004/05/28 13:15:18 $
322
323 </body>
324 </html>