Skip to content
Snippets Groups Projects
Commit cee2dbee authored by Eric Bremner's avatar Eric Bremner
Browse files

ISTWCMS-6771: fixing content list block to use views ajax

parent 583de8ac
No related branches found
No related tags found
1 merge request!32Feature/istwcms 6771 ebremner dashboard ajax
......@@ -85,11 +85,14 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf
// The build array.
$build = [];
// The display id of the view to be used.
$display_id = 'content_list';
// Get the view by machine id.
$view = Views::getView('uw_view_content_list');
// Set the display machine id.
$view->setDisplay('content_list');
$view->setDisplay($display_id);
// Add the content type restriction to the arguments.
$arguments[] = $this->configuration['content_type'];
......@@ -153,23 +156,27 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf
);
}
// Execute the view.
$view->execute();
// Get the title.
$title = $view->getTitle();
// Get the rendered view.
$render = $view->render();
// Get the rendered title for the view.
$the_title_render_array = [
'#markup' => $this->t('@title', ['@title' => $title]),
'#allowed_tags' => ['h2'],
];
// Set the build markup for title and actual view.
$build['view_title'] = $the_title_render_array;
$build['view_output'] = $render;
return $build;
// Display using the view template so ajax works properly.
return [
'#type' => 'view',
'#name' => $the_title_render_array,
'#view' => $view,
'#display_id' => $display_id,
'#embed' => TRUE,
'#cache' => $view->getCacheTags(),
];
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment