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

ISTWCMS-6978: Add code to view all webforms in webform list block on dashboard

parent 18924ce0
No related branches found
No related tags found
1 merge request!38ISTWCMS-6978: Add code to view all webforms in webform list block on dashboard
......@@ -111,6 +111,29 @@ 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.
$total_num_of_results = strtok(
$build['entity_list']['info']['#markup']->__toString(),
' '
);
// If the total number of results is greater than 20, then add
// a link to view all the webforms to the info part of the
// render array.
if ($total_num_of_results > 20) {
$html = $this->t('@count webforms', ['@count' => $total_num_of_results]);
$html .= '<br />';
$html .= $this->t('There are more than 20 webforms, <a href="/admin/structure/webform">View all webforms</a>');
$build['entity_list']['info']['#markup'] = $html;
}
// Remove the pager from the webform list.
unset($build['entity_list']['pager']);
return $build;
}
......
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