Issue #1861852 by dawehner, tim.plunkett: Fixed Views Attachments aren't rendered anymore.
parent
a80680880b
commit
3721a6c5e6
|
@ -254,18 +254,17 @@ class Attachment extends DisplayPluginBase {
|
|||
|
||||
switch ($this->getOption('attachment_position')) {
|
||||
case 'before':
|
||||
$this->view->attachment_before .= $attachment;
|
||||
$this->view->attachment_before[] = $attachment;
|
||||
break;
|
||||
case 'after':
|
||||
$this->view->attachment_after .= $attachment;
|
||||
$this->view->attachment_after[] = $attachment;
|
||||
break;
|
||||
case 'both':
|
||||
$this->view->attachment_before .= $attachment;
|
||||
$this->view->attachment_after .= $attachment;
|
||||
$this->view->attachment_before[] = $attachment;
|
||||
$this->view->attachment_after[] = $attachment;
|
||||
break;
|
||||
}
|
||||
|
||||
$view->destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\views\Tests\Plugin\DisplayAttachmentTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\views\Tests\Plugin;
|
||||
|
||||
/**
|
||||
* Tests the attachment display plugin.
|
||||
*
|
||||
* @see Drupal\views\Plugin\views\display\Attachment
|
||||
*/
|
||||
class DisplayAttachmentTest extends PluginTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_display_attachment');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Display: Attachment plugin',
|
||||
'description' => 'Tests the attachment display plugin.',
|
||||
'group' => 'Views Plugins',
|
||||
);
|
||||
}
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->enableViewsTestModule();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests the attachment plugin.
|
||||
*/
|
||||
protected function testAttachment() {
|
||||
// @todo Remove that once http://drupal.org/node/1828444 got in.
|
||||
state()->set('menu_rebuild_needed', TRUE);
|
||||
|
||||
$this->drupalGet('test-display-attachment');
|
||||
|
||||
$result = $this->xpath('//div[contains(@class, "view-content")]');
|
||||
$this->assertEqual(count($result), 2, 'Both actual view and the attachment is rendered.');
|
||||
|
||||
$result = $this->xpath('//div[contains(@class, "attachment-after")]');
|
||||
$this->assertEqual(count($result), 0, 'The attachment is not rendered after the actual view.');
|
||||
|
||||
$result = $this->xpath('//div[contains(@class, "attachment-before")]');
|
||||
$this->assertEqual(count($result), 1, 'The attachment is rendered before the actual view.');
|
||||
}
|
||||
|
||||
}
|
|
@ -109,18 +109,18 @@ class ViewExecutable {
|
|||
public $total_rows = NULL;
|
||||
|
||||
/**
|
||||
* Rendered attachments to place before the view.
|
||||
* Attachments to place before the view.
|
||||
*
|
||||
* @var string
|
||||
* @var array()
|
||||
*/
|
||||
public $attachment_before = '';
|
||||
public $attachment_before = array();
|
||||
|
||||
/**
|
||||
* Rendered attachements to place after the view.
|
||||
* Attachments to place after the view.
|
||||
*
|
||||
* @var string
|
||||
* @var array
|
||||
*/
|
||||
public $attachment_after = '';
|
||||
public $attachment_after = array();
|
||||
|
||||
// Exposed widget input
|
||||
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
api_version: '3.0'
|
||||
base_field: id
|
||||
base_table: views_test_data
|
||||
core: 8.x
|
||||
description: ''
|
||||
disabled: '0'
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: ''
|
||||
display_options:
|
||||
access:
|
||||
type: perm
|
||||
cache:
|
||||
type: none
|
||||
query:
|
||||
type: views_query
|
||||
exposed_form:
|
||||
type: basic
|
||||
pager:
|
||||
type: full
|
||||
options:
|
||||
items_per_page: '10'
|
||||
style:
|
||||
type: default
|
||||
row:
|
||||
type: fields
|
||||
fields:
|
||||
name:
|
||||
id: name
|
||||
table: views_test_data
|
||||
field: name
|
||||
label: ''
|
||||
alter:
|
||||
alter_text: '0'
|
||||
make_link: '0'
|
||||
absolute: '0'
|
||||
trim: '0'
|
||||
word_boundary: '0'
|
||||
ellipsis: '0'
|
||||
strip_tags: '0'
|
||||
html: '0'
|
||||
hide_empty: '0'
|
||||
empty_zero: '0'
|
||||
link_to_node: '1'
|
||||
title: test_display_attachment
|
||||
page_1:
|
||||
display_plugin: page
|
||||
id: page_1
|
||||
display_title: Page
|
||||
position: '1'
|
||||
display_options:
|
||||
path: test-display-attachment
|
||||
attachment_1:
|
||||
display_plugin: attachment
|
||||
id: attachment_1
|
||||
display_title: Attachment
|
||||
position: '2'
|
||||
display_options:
|
||||
displays:
|
||||
page_1: page_1
|
||||
human_name: test_display_attachment
|
||||
module: views
|
||||
name: test_display_attachment
|
||||
tag: ''
|
|
@ -92,8 +92,18 @@ function template_preprocess_views_view(&$vars) {
|
|||
$vars['pager'] = $view->renderPager($exposed_input);
|
||||
}
|
||||
|
||||
$vars['attachment_before'] = !empty($view->attachment_before) ? $view->attachment_before : '';
|
||||
$vars['attachment_after'] = !empty($view->attachment_after) ? $view->attachment_after : '';
|
||||
if (!empty($view->attachment_before)) {
|
||||
$vars['attachment_before'] = $view->attachment_before;
|
||||
}
|
||||
else {
|
||||
$vars['attachment_before'] = array();
|
||||
}
|
||||
if (!empty($view->attachment_after)) {
|
||||
$vars['attachment_after'] = $view->attachment_after;
|
||||
}
|
||||
else {
|
||||
$vars['attachment_after'] = array();
|
||||
}
|
||||
|
||||
// Add contextual links to the view. We need to attach them to the dummy
|
||||
// $view_array variable, since contextual_preprocess() requires that they be
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
<?php if ($attachment_before): ?>
|
||||
<div class="attachment attachment-before">
|
||||
<?php print $attachment_before; ?>
|
||||
<?php print render($attachment_before); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
@ -67,7 +67,7 @@
|
|||
|
||||
<?php if ($attachment_after): ?>
|
||||
<div class="attachment attachment-after">
|
||||
<?php print $attachment_after; ?>
|
||||
<?php print render($attachment_after); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
|
Loading…
Reference in New Issue