]> git.decadent.org.uk Git - maypole.git/blob - examples/fancy_example/templates/factory/list
added post_chomp as default option for TT
[maypole.git] / examples / fancy_example / templates / factory / list
1 [% PROCESS macros %]
2 [% INCLUDE header %]
3 [% INCLUDE title %]
4 [% IF search %]
5     <div id="title">Search results</div>
6 [% ELSE %]
7     <div id="title">Listing of all [% classmetadata.plural %]</div>
8 [% END %]
9 [% INCLUDE navbar %]
10 <div class="list">
11     <table id="matrix">
12         <tr>
13             [% FOR col = classmetadata.list_columns.list;
14                 NEXT IF col == "id" OR col == classmetadata.table _ "_id";
15                 "<th>"; 
16                 SET additional = "?order=" _ col;
17                 SET additional = additional _ "&page=" _ pager.current_page
18                     IF pager;
19                 SET additional = additional _ "&o2=desc" 
20                 IF col == request.params.order and request.params.o2 != "desc";
21                 SET action = "list";
22                 FOR name = classmetadata.columns.list;
23                   IF request.query.$name;
24                     SET additional =
25                         additional  _ "&" _ name _ "=" _
26                         request.params.$name;
27                     SET action = "search";
28                   END;
29                 END;
30                 USE model_obj = Class request.model_class;
31                 IF model_obj.find_column(col);
32                   link(classmetadata.table, action, additional,
33                     classmetadata.colnames.$col);
34                   IF col == request.params.order;
35                     IF request.params.o2 != "desc";
36                         "&darr;";
37                     ELSE;
38                         "&uarr;";
39                     END;
40                   END;
41                 ELSE;
42                   classmetadata.colnames.$col || col FILTER ucfirst;
43                 END;
44                 "</th>";
45             END %]
46             <th id="actionth">Actions</th>
47         </tr>
48         [%  SET count = 0;
49         FOR item = objects;
50             SET count = count + 1;
51             "<tr";
52             ' class="alternate"' IF count % 2;
53             ">";
54             display_line(item);
55             "</tr>";
56         END %]
57     </table>
58
59 [% INCLUDE pager %]
60 [% INCLUDE addnew %]
61 [% INCLUDE search_form %]
62 </div>
63 [% INCLUDE footer %]