Skip to content
This repository
Browse code

MINOR SSF-297 add more available information to GridField print view

  • Loading branch information...
commit 721184c4b3c8330a8f1d7e26a7e887eea9c12919 1 parent 7f8a682
Normann Lou authored April 04, 2012
14  forms/gridfield/GridFieldPrintButton.php
@@ -131,10 +131,24 @@ function generatePrintData($gridField) {
131 131
 			));
132 132
 			$item->destroy();
133 133
 		}
  134
+		
  135
+		//get title for the print view
  136
+		$form = $gridField->getForm();
  137
+		$currentController = Controller::curr();
  138
+		$title = method_exists($currentController, 'Title')?$currentController->Title():
  139
+					($currentController->Title?$currentController->Title:
  140
+					($form?$form->Name():''));
  141
+		if($fieldTitle = $gridField->Title()) $title .= ($title?' - ':'').$fieldTitle;
  142
+		
  143
+		//$state = $gridField->getState(false)->__toString();
  144
+		
134 145
 		$ret = new ArrayData(
135 146
 			array(
  147
+				"Title" => $title,
136 148
 				"Header" => $header,
137 149
 				"ItemRows" => $itemRows,
  150
+				"Datetime" => SS_Datetime::now(),
  151
+				"Member" => Member::currentUser(),
138 152
 			)
139 153
 		);
140 154
 		
7  templates/Includes/GridField_print.ss
... ...
@@ -1,8 +1,10 @@
1 1
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//MI" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 2
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="mi" lang="mi">
3 3
 	<head>
  4
+		
4 5
 	</head>
5 6
 	<body>
  7
+		<% if $Title %><h3>$Title</h3><% end_if %>
6 8
 		<table>
7 9
 			<thead>
8 10
 				<tr><% control Header %><td>$CellString</td><% end_control %></tr>
@@ -13,5 +15,10 @@
13 15
 				<% end_control %>
14 16
 			</tbody>
15 17
 		</table>
  18
+		<p>
  19
+			Printed at $Datetime.Nice
  20
+			<br />
  21
+			Printed by $Member.Name
  22
+		</p>
16 23
 	</body>
17 24
 </html>

0 notes on commit 721184c

Please sign in to comment.
Something went wrong with that request. Please try again.