Skip to main content

PDF for GravityView Hooks – gfpdf_gv_multiple_entries_layout

Description​

Choose how the Multiple Entries PDF for a Table or DataTables View lays out its columns:

  • table: a real table. Columns line up from row to row, the column header repeats at the top of every page, and the PDF is denser and faster to generate. This is the default.
  • float: each row is built from side-by-side blocks. The column header prints once above the first row and once below the last.

Block-level content renders poorly inside a table cell, so the PDF switches to float when any column is one of these:

  • An HTML field
  • An embedded View (the GravityView View field)
  • A Repeater field
  • A Paragraph field with the rich text editor turned on
  • A Custom Content field that uses the {all_fields} or {pricing_fields} merge tag
  • A field type added with gfpdf_gv_table_div_field_types

If a View's column header stopped repeating on each page, this is usually why. Use this filter to switch a View back to table, or to force float. Check the PDF after switching to table: headings, lists and nested Views in a table cell can come out cramped or split badly across pages.

Views using the List, DIY, Layout Builder or Map layout don't use this filter.

Version​

This hook was introduced in PDF for GravityView 2.0.

Arguments​

The following arguments are passed to functions that use this hook:

$layout | string​

  • How the table is laid out: table or float. Any other value is treated as table.
  • The default value is float when any column holds block-level content (see above), and table otherwise.

$view | \GV\View​

  • The View the PDF is being generated for.

$fields | \GV\Field[]​

  • The table's columns, in order.

Usage​

Keep the repeating column header on View 885, even though it has an HTML column:

add_filter( 'gfpdf_gv_multiple_entries_layout', function( $layout, $view, $fields ) {
if ( (int) $view->ID === 885 ) {
return 'table';
}

return $layout;
}, 10, 3 );

Only use float for embedded Views, and table for everything else:

add_filter( 'gfpdf_gv_multiple_entries_layout', function( $layout, $view, $fields ) {
foreach ( $fields as $field ) {
if ( $field->type === 'gravityview_view' ) {
return 'float';
}
}

return 'table';
}, 10, 3 );

Source Code​

This filter is located in src/Pdf/Templates/gravityview-directory-entry-table-template.php of the PDF for GravityView extension.