Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 721184c4b3c8330a8f1d7e26a7e887eea9c12919 1 parent 7f8a682
@normann normann authored
View
14 forms/gridfield/GridFieldPrintButton.php
@@ -131,10 +131,24 @@ function generatePrintData($gridField) {
));
$item->destroy();
}
+
+ //get title for the print view
+ $form = $gridField->getForm();
+ $currentController = Controller::curr();
+ $title = method_exists($currentController, 'Title')?$currentController->Title():
+ ($currentController->Title?$currentController->Title:
+ ($form?$form->Name():''));
+ if($fieldTitle = $gridField->Title()) $title .= ($title?' - ':'').$fieldTitle;
+
+ //$state = $gridField->getState(false)->__toString();
+
$ret = new ArrayData(
array(
+ "Title" => $title,
"Header" => $header,
"ItemRows" => $itemRows,
+ "Datetime" => SS_Datetime::now(),
+ "Member" => Member::currentUser(),
)
);
View
7 templates/Includes/GridField_print.ss
@@ -1,8 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//MI" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="mi" lang="mi">
<head>
+
</head>
<body>
+ <% if $Title %><h3>$Title</h3><% end_if %>
<table>
<thead>
<tr><% control Header %><td>$CellString</td><% end_control %></tr>
@@ -13,5 +15,10 @@
<% end_control %>
</tbody>
</table>
+ <p>
+ Printed at $Datetime.Nice
+ <br />
+ Printed by $Member.Name
+ </p>
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.