Closed (fixed)
Project:
Workflow
Version:
5.x-1.2
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
13 Apr 2008 at 19:59 UTC
Updated:
26 May 2010 at 06:23 UTC
I need to theme node display differently based on the state of the node. How can I access the node state inside node.tpl.php
so I can show nodes with different state differently? What variables available there?
Comments
Comment #1
jvandyk commentedWorkflow 5.x-1.2's hook_nodeapi() implementation loads the current workflow state into $node->_workflow. This is an integer representing the state ID of the current workflow state for the node. That may be all you need.
If you need the actual state name, you can get it like this (but it will cost you a database query): $state_info = workflow_get_state($node->_workflow), which will return an array of information about the state. You could then see the state name in $state_info['state'].
Comment #2
gaellafond commentedNOTE:
In some case, the variable will be
$node->workflowinstead of$node->_workflow.See: http://drupal.org/node/477780
If you just want the name, it seem to be faster to call
workflow_get_state_nameinstead ofworkflow_get_state.I got the following code to get the Workflow name: