You are here

function hook_workbench_content_alter in Workbench 8

Same name and namespace in other branches
  1. 7 workbench.api.php \hook_workbench_content_alter()

Allows modules to alter the default Workbench landing page.

This hook is a convenience function to be used instead of hook_page_alter(). In addition to the normal Render API elements, you may also specify a #view and #view_display attribute, both of which are strings that indicate which View to render on the page.

The left and right columns in this output are given widths of 35% and 65% respectively by workbench.my-workbench.css.

Workbench assumes that all elements on the page are Views, keyed by the '#view_id' and '#view_display' elements of the $output array.

If you wish to substitute another renderable element, you may do so by unsetting those paramaters and providing a render array of your own.

Parameters

array $output: A Render API array of content items, passed by reference.

$context: A string context for the request, defaults to overview|edits|all.

Return value

array A renderable array or an array keyed with a #view_id and #view_display to indicate which View display to load onto the page.

See also

WorkbenchContentController::renderBlocks()

3 invocations of hook_workbench_content_alter()
WorkbenchContentController::allContent in src/Controller/WorkbenchContentController.php
Page callback for the workbench content page.
WorkbenchContentController::content in src/Controller/WorkbenchContentController.php
Page callback for the workbench content page.
WorkbenchContentController::editedContent in src/Controller/WorkbenchContentController.php
Page callback for the workbench content page.

File

./workbench.api.php, line 36
API documentation file for Workbench.

Code

function hook_workbench_content_alter(&$output, $context = NULL) {

  // Replace the default "Recent Content" view with our custom View.
  $output['workbench_recent_content']['#view_id'] = 'custom_view';
  $output['workbench_recent_content']['#view_display'] = 'block_2';

  // Replace the 'workbench_current_user' view entirely.
  $output['workbench_current_user'] = [
    '#type' => 'markup',
    '#markup' => t('Welcome to Fantasy Island!'),
  ];
}