Skip to content

Commit

Permalink
MINOR SSF-297 add more available information to GridField print view
Browse files Browse the repository at this point in the history
  • Loading branch information
normann committed Apr 4, 2012
1 parent 7f8a682 commit 721184c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions forms/gridfield/GridFieldPrintButton.php
Expand Up @@ -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(),
)
);

Expand Down
7 changes: 7 additions & 0 deletions 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>
Expand All @@ -13,5 +15,10 @@
<% end_control %>
</tbody>
</table>
<p>
Printed at $Datetime.Nice
<br />
Printed by $Member.Name
</p>
</body>
</html>

0 comments on commit 721184c

Please sign in to comment.