This is an old wish of mine, and appears to be necessary for #2102409: [META] Support multiple workflow_fields per Node type (Entity bundle).

1. Some people would like to customize the Workflow Tab more to their needs.
2. If you have 2 workflow fields on 1 entity type/bundle, then the current workflow tab is useless. It is also not Programmable: "which of the workflow fields should you show? In which order? What if a user only has access to one of the workflows?"

Here is a recipe for this:
- disable 'Use the workflow history tab' in the settings of your Workflow Field (optional);
- create a new view mode 'workflow' on the entities with workflows;
- create a new view 'workflow history tab', with 2 parts: a 'page' with a rendered entity in view mode 'workflow', and an 'attachment' with a list of transitions;
- test all cases (entities with/without workflow, users with/without access)
- set the view mode to your needs;

Moving the 'workflow tab' into a view makes the following code obsolete:
- workflow_tab_page(), which shows the page;
- workflow_tab_access(), which defines a access routine;
- workflow_menu, which defines menu items;

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

johnv’s picture

Please find attached:
- a patch to create a new view_mode;
- a view, which you can import;
See the recipe above to use this.

johnv’s picture

Title: Have Workflow Tab as a Views display » Have more flexible Workflow Tab as a Views display (allowing multiple Workflow_fields per bundle, too )

  • Commit 1bf5dc1 on 7.x-2.x by johnv:
    Issue #2217291: Added new view + view_mode 'history_tab', to create...
  • Commit 7321195 on 7.x-2.x by johnv:
    Issue #2217291: Added new view + view_mode 'history_tab', to create...
johnv’s picture

A new view 'history per entity' is created. It is disabled by default.
You can use it to change the appearance of the workflow_tab.
To change the first half of the page (the workflow form), you can change the View mode of entities.
To change the second part of the page, change the 'Attachment' display of the View.

johnv’s picture

Version: 7.x-2.x-dev » 7.x-2.2
Status: Active » Fixed
preddy’s picture

method 'workflow_views_entity_info_alter ':

Need to handle 'field_info_field_map()' method for drupal version prior to 7.22.

$field_map_available = version_compare(VERSION, '7.22', '>=');
$field_maps = $field_map_available ? field_info_field_map() : field_info_fields();

  • Commit 04a6cbc on 7.x-2.x by johnv:
    Issue #2217291: Fixed workflow_views for installations with D7<7.22.
    
johnv’s picture

Thanks.
I already have a function for that. Fixed with above commit.

johnv’s picture

Title: Have more flexible Workflow Tab as a Views display (allowing multiple Workflow_fields per bundle, too ) » Have more flexible Workflow Tab as a Views display (allowing multiple Workflow_fields per bundle, too)
Issue summary: View changes
Status: Fixed » Closed (fixed)
Issue tags: -D8

  • Commit 0556052 on 7.x-2.x by johnv:
    Issue #2217291: Removed warnings from workflow_views, when another...
johnv’s picture

Title: Have more flexible Workflow Tab as a Views display (allowing multiple Workflow_fields per bundle, too) » Workflow Tab as a Views display (allowing multiple Workflow fields per bundle, too)