Hi there,

I've got a problem with the field "States: State machine name" in views. I've added this option to my view as an additional field. When displaying the view some nodes appear twice or 3 times - according to the number of states the nodes are in. In my case this is a "wrong" behaviour. I only want to display the recent (last) state the nodes are in. How can I achieve this?

Thanks for any help, Bjoern

Comments

bjacob’s picture

Other question: if I can't fix the problem mentioned above is there a way to create a new field which displays the recent status in a view? I really need your help guys...

fago’s picture

Status: Active » Fixed

hm, I think that's due to different node revisions having different states. Try to filter to your latest revision.

bjacob’s picture

fago, thanks for your help. Sorry but right now I don't know how to filter my latest revision. As fa as I'm concerned I've never created a node revision. Can you tell me how to filter revisions?

Again another question: is there any reason for storing the old states? Why don't we delete the states in {node_state} and only keep the recent one?

Thanks again for your help.

fago’s picture

>is there any reason for storing the old states
It's the way node revision work.

hm, I had a short look at it and I don't think it would list multiple revisions - it should list just the active one.
Do your result contain all the same state machine name? If yes, the problem is probably that there are multiple entries in the table where there shouldn't be multiple.. per revision and state machine should be just one entry.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

bjacob’s picture

Status: Closed (fixed) » Active

Sorry for not answering for such a long time. The problem still exists. For example someone creates a new node. The state "pending" (cce_cclink0) is assigned automatically. Then the administrator of the page reviewes the node and clicks a workflow_ng link to assign a new state called "approved" (cce_cclink3). In my special case now a user is able to verify as owner of the node. I've created a module for this verification process. In the end (assumed everything is okay) a new state "verified" (cce_cclink4) is automatically assigned to the node. At that time I've got three entries in {node_state} regarding the node (one entry for each state).

A workaround would be to delete the old states "manually". I could add the delete query to my workflow actions to delete the previous states. Nevertheless, it would be great if someone could help me with the problem. Is there a built-in delete function which comes with workflow_ng?

EDIT: Maybe I'm using the function states_machine_set_state() wrong. As I said I'm using actions to set the new states. The PHP code looks like this:

//set state to approved
states_machine_set_state($node, 'cce_cclink3', 'clicked');

I've read the documentation for the function:

* @param $machine_name The machine readable state machine name
* @param $state The value to set for the state machine

Any ideas?

fago’s picture

Status: Active » Fixed

hm, these state machines created by cclink are used for remembering the links state. I think you should not rely on that for your state, but use a separate state machine for that. Then you don't run into troubles with "old" states, as you have only one state machine which is of interest for you. However, you have to write some lines of code to generate another state machine.

Anyway you could also use a CCK field for storing your state.

bjacob’s picture

Thanks for your answer. I've created all the functions nearly 1.5 years ago. Drupal was totally new for me and maybe I didn't understand the whole idea of your awesome module. I think I started building my site with workflow_ng 5.1.x. Later you released 5.2.x and I think the custom state machines stuff was a new feature (or at least much better than in version 5.1)...

So you're saying instead of using content links I should create "real" state machines? Mmh, I don't know if this is possible at the recent state of my project. The whole website relies on the states (or content links) I've introduced. Coming up with a new state structure would result in completely rebuilding my site :( Do you think it'll be a problem to delete the old entries from the node_state table? If not I'll live with the wrong usage of content links and states and implement the above mentioned workaround.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.