Skip to content

Instantly share code, notes, and snippets.

@robdecker
Last active November 2, 2019 02:07
Show Gist options
  • Save robdecker/51e14ea355ee98eac6b9 to your computer and use it in GitHub Desktop.
Save robdecker/51e14ea355ee98eac6b9 to your computer and use it in GitHub Desktop.
[Views: only display a views attachment of the first page of results] #d7
<?php
function yourmodule_views_post_build($view) {
$view_name = 'the_id_of_the_view';
// The display ID of the main view display.
$display_id = 'page_1';
if ($view->name == $view_name && $view->current_display == $display_id) {
$current_page = $view->get_current_page();
// Hide the attachments on all pages beside the first one.
if ($current_page > 0) {
$view->attachment_before = '';
$view->attachment_after = '';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment