]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Maypole/templates/factory/macros
fix for CGI handler when fatal error, improved makefile
[maypole.git] / lib / Maypole / templates / factory / macros
index cbf58bb21902fd0b1f80a907190363aa184ecf1b..ddaeae1bf8e23bff911e551561a3df504fafb1d8 100644 (file)
@@ -10,12 +10,20 @@ system.
 This creates an <A HREF="..."> to a command in the Apache::MVC system by
 catenating the base URL, table, command, and any arguments.
 
+arguments are table, command, additional, label, target.
+
+target specifies a target for the link if provided.
+
 #%]
 [%
-MACRO link(table, command, additional, label) BLOCK;
+MACRO link(table, command, additional, label, target) BLOCK;
     SET lnk = base _ "/" _ table _ "/" _ command _ "/" _ additional;
-    lnk = lnk | uri | html;
-    '<a href="' _ lnk _ '">';
+    lnk = lnk | uri ;
+    IF target ;
+       '<a href="' _ lnk _ '" target="' _ target _'">';
+    ELSE;
+       '<a href="' _ lnk _ '">';
+    END;
     label | html;
     "</a>";
 END;
@@ -56,15 +64,19 @@ for some.
 [% MACRO display_line(item) BLOCK;
     FOR col = classmetadata.list_columns;
        NEXT IF col == "id" OR col == classmetadata.table _ "_id";
+       col_obj = item.find_column(col);
         "<td>";
         IF col == "url" AND item.url;
             '<a href="'; item.url | html ; '"> '; item.url; '</a>';
         ELSIF col == classmetadata.stringify_column;
             maybe_link_view(item);
-        ELSE;
-            accessor = item.accessor_name(col);
+               ELSIF col_obj; # its a real column
+            accessor = item.accessor_name_for(col_obj) || item.accessor_name(col_obj); # deprecated in cdbi
             maybe_link_view(item.$accessor);
+        ELSE; 
+            item.$col;
         END;
+
         "</td>";
     END;
     '<td class="actions">';
@@ -133,7 +145,7 @@ This takes an object and and displays its properties in a table.
     [% INCLUDE navbar %]
     <table class="view">
         <tr>
-            <td class="field">[% classmetadata.colnames.$string %]</td>
+            <td class="field">[% classmetadata.colnames.$string  %]</td>
             <td>[% item.$string | html %]</td>
         </tr>
         [% FOR col = classmetadata.columns.list;
@@ -149,11 +161,18 @@ from the C<column_names> method:
 
 #%]
             <tr>
-                <td class="field">[% classmetadata.colnames.$col; %]</td>
+                <td class="field">[% classmetadata.colnames.$col || 
+                     col | ucfirst | replace('_',' '); %]</td>
                 <td>
                     [% IF col == "url" && item.url;  # Possibly too much magic.
                         '<a href="'; item.url | html ; '"> '; item.url; '</a>';
+                                       ELSIF item.$col.size > 1; # has_many column
+                                               FOR thing IN item.$col; 
+                                                       maybe_link_view(thing);",  ";
+                                                END;
+
                     ELSE;
+                                       
                         maybe_link_view(item.$col); 
                     END; %]
 [%#