|
2 | 2 | Customising Roundup |
3 | 3 | =================== |
4 | 4 |
|
5 | | -:Version: $Revision: 1.92 $ |
| 5 | +:Version: $Revision: 1.93 $ |
6 | 6 |
|
7 | 7 | .. This document borrows from the ZopeBook section on ZPT. The original is at: |
8 | 8 | http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx |
@@ -2432,43 +2432,48 @@ that when you click on "Search Issues" it will be looking for a |
2432 | 2432 | ``issue.search.html`` file to display. So that is the file that we will |
2433 | 2433 | change. |
2434 | 2434 |
|
2435 | | -This file should begin to look familiar, by now. It is a simple HTML |
2436 | | -form using a table to define structure. You can add the new category |
2437 | | -search code anywhere you like within that form:: |
2438 | | - |
2439 | | - <tr> |
2440 | | - <th>Category:</th> |
2441 | | - <td> |
2442 | | - <select name="category"> |
2443 | | - <option value="">don't care</option> |
2444 | | - <option value="">------------</option> |
2445 | | - <option tal:repeat="s db/category/list" |
2446 | | - tal:attributes="value s/name" |
2447 | | - tal:content="s/name">category to filter on</option> |
2448 | | - </select> |
2449 | | - </td> |
2450 | | - <td><input type="checkbox" name=":columns" value="category" |
2451 | | - checked></td> |
2452 | | - <td><input type="radio" name=":sort" value="category"></td> |
2453 | | - <td><input type="radio" name=":group" value="category"></td> |
2454 | | - </tr> |
2455 | | - |
2456 | | -Most of this is straightforward to anyone who knows HTML. It is just |
2457 | | -setting up a select list followed by a checkbox and a couple of radio |
2458 | | -buttons. |
| 2435 | +If you look at this file it should be starting to seem familiar, although it |
| 2436 | +does use some new macros. You can add the new category search code anywhere you |
| 2437 | +like within that form:: |
| 2438 | + |
| 2439 | + <tr tal:define="name string:category; |
| 2440 | + db_klass string:category; |
| 2441 | + db_content string:name;"> |
| 2442 | + <th>Priority:</th> |
| 2443 | + <td metal:use-macro="search_select"></td> |
| 2444 | + <td metal:use-macro="column_input"></td> |
| 2445 | + <td metal:use-macro="sort_input"></td> |
| 2446 | + <td metal:use-macro="group_input"></td> |
| 2447 | + </tr> |
2459 | 2448 |
|
2460 | | -The ``tal:repeat`` part repeats the tag for every item in the "category" |
2461 | | -table and sets "s" to each category in turn. |
| 2449 | +The definitions in the <tr> opening tag are used by the macros: |
2462 | 2450 |
|
2463 | | -The ``tal:attributes`` part is setting up the ``value=`` part of the |
2464 | | -option tag to be the name part of "s", which is the current category in |
2465 | | -the loop. |
| 2451 | +- search_select expands to a drop-down box with all categories using db_klass |
| 2452 | + and db_content. |
| 2453 | +- column_input expands to a checkbox for selecting what columns should be |
| 2454 | + displayed. |
| 2455 | +- sort_input expands to a radio button for selecting what property should be |
| 2456 | + sorted on. |
| 2457 | +- group_input expands to a radio button for selecting what property should be |
| 2458 | + group on. |
2466 | 2459 |
|
2467 | | -The ``tal:content`` part is setting the contents of the option tag to be |
2468 | | -the name part of "s" again. For objects more complex than category, |
2469 | | -obviously you would put an id in the value, and the descriptive part in |
2470 | | -the content; but for categories they are the same. |
| 2460 | +The category search code above would expand to the following:: |
2471 | 2461 |
|
| 2462 | + <tr> |
| 2463 | + <th>Category:</th> |
| 2464 | + <td> |
| 2465 | + <select name="category"> |
| 2466 | + <option value="">don't care</option> |
| 2467 | + <option value="">------------</option> |
| 2468 | + <option value="1">scipy</option> |
| 2469 | + <option value="2">chaco</option> |
| 2470 | + <option value="3">weave</option> |
| 2471 | + </select> |
| 2472 | + </td> |
| 2473 | + <td><input type="checkbox" name=":columns" value="category"></td> |
| 2474 | + <td><input type="radio" name=":sort" value="category"></td> |
| 2475 | + <td><input type="radio" name=":group" value="category"></td> |
| 2476 | + </tr> |
2472 | 2477 |
|
2473 | 2478 | Adding category to the default view |
2474 | 2479 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
0 commit comments