Dear Drupalers,

Could someone tell me how I could show the worflow status of a node within it's content? (And eventually following to the nodetype within the search results)

I guess there is a simple PHP "Print" command to put in my page.tpl.php or in my node-type.tpl.php files, but I don't know how.

Which function to call? May the token.module help me? Will the specific functions to call be different in workflow_ng (I may migrate)?

Many thanks!

Arsène

Comments

doc2@drupalfr.org’s picture

Maybe my previous question was not clear enough... here my second try...

I would like that the status (from the workflow module) gets displayed in the node content?

Any ideas how I could patch things?

Many thanks in advance for your input.

Arsène

doc2@drupalfr.org’s picture

All right, I think I got a piece of a hint with the workflow_field.module : http://drupal.org/project/workflow_fields

Now that I have a workflow_field dedicated to my node's state, I'd like to have it automatically filled with the current worflow state.

1 - As it is possible to define a default value to fields:

> http://arsene.richard.free.fr/ged/workflow_state/Workflow_field-PHP_defi...

2 -... and moreover to have some PHP code that would do it

... I thought that some clever devz would catch the occasion to give me a hand!

A kind of a good clue: Here is a PHP snipet of what should fit, somehow, into place 1-. It's taken from the workflow.module from line to line. But only the line 128 seems useful:

> http://arsene.richard.free.fr/ged/workflow_state/Workflow_current_state_...

Hope I've been clear enough! Or let me know.

doc2@drupalfr.org’s picture

I made "fausse route" with this workflow_field.module... the English language is sometimes tricky!!!

Currently, I try to achieve that feature with the views_argument_api.module but I have no result yet..:

- node id argument EQUALS $node (1)
- workflow:state field chosen to show up in a...
- block view

-> Did I miss something?

Eventually, I'd use something like view_field to put my result within the node content... whenever I'll get this result!

(1) I used $node according to http://drupal.org/node/160921#comment-254062 yet this comment has been criticized. I had a look at but I am not enough experimented to understand everything...

Any help welcome!

doc2@drupalfr.org’s picture

Well, in fact I managed it fine with workflow_fields! Just had to persevere.

Here's a draft, and I thought I could be able to edit it later on... http://drupal.org/node/209868 Sorry for the poor quality. I wish I could delete it...

el_reverend’s picture

Hello Doc2,

I tried to follow your instructions, but I am unable to do so. Specifically Point 5 (Section B) is the culprit. Could you elaborate on that a little bit?

Greatly appreciated

doc2@drupalfr.org’s picture

At the time, I wasn't able to theme my templates. Now that I can, I suggest that you use theming which is probably much more ressource efficient than the module settings I suggested by then.

In fact you may just need to write this piece of code somewhere in your node-tpl.php file:

print get_status_name($node->_workflow);

In my zen theme, I have this :

<?php if ($teaser): ?>  <!-- START OF "NON TEASER" THEME -->
  <?php else: ?>  <!-- I don't want the author infos to show up in my teaser views. -->
    <?php if ($submitted): ?>
      <span class="unsub">
        <?php if(user_access('administer nodes'))   // I want the author infos to show up only to users who have "administer nodes" access.
        print get_node_type_name($node->nid).', '.get_status_name($node->_workflow).', '.$submitted.' '.novocname_taxonomy_links($node, 37,null,'link'); ?>  <!-- I want to respectively display in the "submitted div": the nodetype, the workflow state, the author infos and finally the terms of an admin vocab witnessing the completeness of the node, separated by commas. -->
      </span> 
    <?php endif; ?>
  <?php endif; ?>  <!-- END OF "NON TEASER" THEME -->

There must be an "endif" lacking but I don't exactly know where as I haven't made the code myself.

Hope this will work for you. Good luck!

stacysimpson’s picture

I started playing around with some solutions, but I cannot find the referenced function, get_status_name, any where. Can you point me towards the implementation?

freddyseubert’s picture

I also searched for that "get_status_name" function and didn't find it anywhere...

Perhaps there is a custom function in the template.php of your zen theme?

Edit: Now I saw the date of this thread... hmpf

Edit2: I found this one in the issue queue of the workflow module: http://drupal.org/node/107138#comment-487291 - and I think, it will help ;)

gaellafond’s picture

The function get_status_name do not seem to exists in Drupal 6.
If this solution do not work for you, see:
http://drupal.org/node/246195

I use the following code to get the Workflow name:

if (isset($node->_workflow)) {
  $workflowId = $node->_workflow;
} elseif (isset($node->workflow)) {
  $workflowId = $node->workflow;
}

[...]

if (isset($workflowId)) {
  // I only display the workflow name in some cases.
  // So, I call workflow_get_state_name only when I need it.
  $workflowName = workflow_get_state_name($workflowId);
  [...]
}