Last updated March 6, 2012. Created by stevector on May 27, 2011.
Edited by pfrenssen, wmostrey. Log in to edit this page.
API
Workbench does not offer a generic API. Please check the other Workbench modules like Workbench Access for descriptions of their APIs.
Database Schema
Workbench does not create any tables during installation. Other Workbench modules like Workbench Access and Workbench Moderation create tables. Please review each module's README.txt file to learn more about schema changes.
Views Integration
Workbench creates several base views for the My Content tab. Other Workbench modules further alter these views. You can alter the views via Views UI as well.
If you wish to keep your altered Views in code you may want to clone and rename them. You can also use hook_views_default_views_alter() to override the View definition coming from the Workbench module itself. The latter approach will allow your changes to be picked up by the stock 'My Workbench' UI.
The hook hook_views_default_views_alter() can be implemented in a custom module with a snippet like the following.
<?php
/**
* Implements hook_views_default_views_alter().
*/
function custom_views_default_views_alter(&$views) {
$files = file_scan_directory(drupal_get_path('module', 'custom'). '/views/altered', '/inc$/');
foreach ($files as $filename => $file) {
if (isset($views[$file->name])) {
require $filename;
$views[$file->name] = $view;
}
}
}
?>This will scan with the custom module for files like views/altered/name_of_view.inc.
You can also change the View settings directly. Say for example you want to restrict access to the Recent Content view to administrators only:
<?php
/**
* Implements hook_views_default_views_alter().
*/
function custom_views_default_views_alter(&$views) {
if (isset($views['workbench_recent_content'])) {
$admin_role = user_role_load_by_name('administrator');
$views['workbench_recent_content']->display['default']->display_options['access'] = array(
'type' => 'role',
'role' => array($admin_role->rid => $admin_role->rid),
);
}
}
?>