Skip to content
Snippets Groups Projects
Commit b4d455da authored by Chris Shantz's avatar Chris Shantz
Browse files

Merge branch '1.0.x' into prod/1.0.x

parents 392c2f41 7fe67cb7
No related branches found
No related tags found
1 merge request!44Feature/istwcms 7264 kpaxman remove dashboard blocks
......@@ -111,6 +111,35 @@ class FormsListBlock extends BlockBase implements ContainerFactoryPluginInterfac
// Render the entity list.
$build['entity_list'] = $render;
// Get the total number of results. There was no easy way
// to get this value from the render array, either using the
// translatable markup, of the entity list builder. The only
// way was the get the actual string and pick off up to the
// first space.
if (
count($build['entity_list']['info']) > 0 &&
isset($build['entity_list']['info']['#markup'])
) {
$total_num_of_results = strtok(
$build['entity_list']['info']['#markup']->__toString(),
' '
);
}
else {
$total_num_of_results = 0;
}
// If the total number of results is greater than 50, then add
// a link to view all the webforms to the info part of the
// render array.
if ($total_num_of_results > 50) {
$build['entity_list']['info']['#markup'] .= $this->t('<br><a href="../admin/structure/webform">View all webforms</a>');
$build['entity_list']['more_info']['#markup'] = $this->t('<p class="pager__items"><a href="../admin/structure/webform?page=1">Next ›</a></p>');
}
// Remove the pager from the webform list.
unset($build['entity_list']['pager']);
return $build;
}
......
......@@ -122,3 +122,35 @@ function uw_dashboard_entity_type_alter(array &$entity_types) {
// This should ensure all works as before, except is new function is called.
$entity_types['webform']->setHandlerClass('list_builder', UWWebformEntityListBuilder::class);
}
/**
* Implements hook_views_pre_execute().
*/
function uw_dashboard_views_pre_execute(ViewExecutable $view) {
// Have a variable that can be used "globally".
static $view_instances_count;
// If there is no count yet, set it to 0.
if (!isset($view_instances_count)) {
$view_instances_count = 0;
}
// The views that need the pager id adjusted.
$view_ids = [
'uw_view_content_list',
'uw_view_pub_reference',
'uw_view_pub_keywords',
'uw_view_pub_authors',
];
// If a view needs its pager id adjusted, then do it.
if (in_array($view->id(), $view_ids)) {
// Increment the counter, so we get the correct pager id.
$view_instances_count++;
// Set the pager id in the view.
$view->pager->options['id'] = $view_instances_count;
}
}
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