Changing states through links.

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
keesee's picture

I am attempting to set up a node type that has 4 workflow states associated to it. What I would like to do is include links or linked images images and via the link, can be clicked on to change that node to that state. The idea is to keep users from having to click workflow and then change the state. These states will not change, so I don't mind hardcoding links into the node template and using node id as a dynamic variable in the url. Is this possible? I think that this would be a great usability enhancement to Workflows aswell. thanks in advance. Jimmy

Comments

nice idea

fago's picture

That's a nice idea. Is there always only one possible transition, so that there is always only one link?

I'm currently working on the "configureable content links" module for workflow-ng - with it links can be used to toggle a state of a node, however only toggling is supported, not more than two states... But it also supports scheduling.
To test use the workflow-ng dev snapshot or the next beta, which I'll release tomorrow.

explanation

keesee's picture

Sorry Fago, I somehow skipped over the question. No there will be four states, and you can change from one state to any of the other 3 at any time. I have created an image with four quadrants and layed it into a div as the background, then create a transparent gif that can be sized and layer over the top of each quadrant that links (workflow execute transition) as suggested below.

The background image is specific to the state. I created 4 of them, all the same except the quadrant highlighted. I named them the id (2.gif, 3.gif etc) for each state and then when I placed image I used the State variable.gif

not sure how clear this is. The images placement is done... all that I am working on now is changing states from the view page (in one click), rather than the edit of workflow pages.

--
J.

Transition by link in view

mudd's picture

CorpX or others,

I'm looking for exactly the same thing CorpX describes above -- a way to place buttons/links on the node page, which when clicked evoke a state change (transition).

(I'm referring to a node displayed in any of several ways; the node as it's own web page, in a list, etc -- Can you tell I'm very new to Drupal?)

The application I'm building is a place for contributors to post content, and each post needs to be created (eg, draft), submitted, reviewed, approved, posted, rejected, revoked, etc.

I'd like to place links on a node's regular view (perhaps also list views) such that a "Submit" link appears only for the author, and only when in Draft state; an "Accept" link for only the reviewer role and only when in Submitted state; "Approve" and "Reject" links only for release-check role and in Accepted state; etc... (Reject would also have a textarea (expandable or popup) for entering notes to be emailed to the author)

These links could be in the node view or on a block, but they change depending on what state the node is in and the role of the visitor. (I really like CorpX's concept of the BG image depicting the current state, but a simple label would suffice.)

I'm hunting for examples of implementing this through workflow_execute_transition() as caign recommends, but haven't had any revelations.

Does anyone know of a module for this? (Fastoggle doesn't seem to have the flexibility I'm hoping for, and if there's a way to extend it... well, I'm just not there yet.) Thanks!

fasttoggle?

jaydub's picture

Not sure if this fits the bill but I think the fasttoggle module offers what you want: http://drupal.org/project/fasttoggle

Another way to achieve this

boaz_r's picture

I haven't done it but I've played enough with workflow and actions module to think that this can be done also by creating custom "actions" to move a node's workflow. Then, you can programatically fire up an action when a link is pressed (for example, by having the link point to a PHP based page (filter), which will redirect to the page you came from, but also fire up the action).
Through manually creating actions to move a node to the specified state you can do it.
I must note that the above requires relatively deep programming as you'll need to code the actions, look for exact workflow state information (what to move the node to. I'm not sure its a single column in a table (?)) and generally speaking do lots of things via code, not the Drupal interface.
The added value is that it can be interesting and challenging! :-)

Good luck!
Boaz.

PHP therapist
Linnovate

Boaz
PHP therapist

workflow_execute_transition

Mark Matuschka's picture

Instead of going to all this trouble, why not code a call to workflow_execute_transition()?

--
Mark Matuschka
Glo Digital

True; One learn new things every day... :-)

boaz_r's picture

PHP therapist
Linnovate

Boaz
PHP therapist

this resource is great.

keesee's picture

thank you all for the responses. I may inquire as to help on this later when I am ready to implement it. I would also like to do a book page on this so that other may benefit. I can't be the only one wanting to figure this out : )

Thx again.

How do I call workflow_execute_transition()?

EdoP's picture

Hi Mark,
sorry for the noob question, but how would I code such a call?
What I am looking for is a dynamic to do list with 2 workflow states that I can change from a view, using 2 links per line: Add to to do list / Remove from to do list. A checkbox toggle would work fine too. The idea is to have the view filter on the To do state. I find the regular workflow change interface to do this a little confusing for end user, hence the idea of using links. Any ideas?
** Update: I found that Flag works much better in my case, it's more user friendly. Only works with 2 states though, so I imagine others may still be interested in my question.

videographics's picture

This is an old thread but here are some ideas from my recent work in this realm...

I think if you're looking to manage transitions between states, and you need something beyond a Flag or a simple Select field, the answer you're looking for is ultimately related to Rules. Rules can easily manage transition from one workflow state to another—regardless of whether you're using the Workflow module or a simple select field to store your state.

So, then the question becomes, how to trigger the rules... You can use a variety of techniques including the Flag module which you've already discovered. In some cases, you might even use the Flag module strictly to trigger rules that change a value elsewhere—instead of using the Flag module to store your Workflow values. This technique would enable you to have more than two states with a variety of interface options.

You might also look at Rules Link which is designed to trigger rules using links in views.

(If you're brave, you could also try Rule Bonus Pack which can trigger rules from a path using Page Manager. Rule Bonus Pack is not a maintained module, so one really shouldn't rely on it for real work, but I've found this one particular function to work flawlessly. It can also use Page Manager to pass arguments to Rules which opens even more possibilities. Basically, you can trigger the rules from anywhere you can put a link including buttons, jump menus, and even other sites. You can also trigger rules while passing along any number of arguments from virtually any context. I think this is really, really cool. I'd strongly prefer this method if it were better supported. If this Page Manager Reaction function were only its own maintained module...)

Lastly, if you're using the Workflow module, consider that it's not the only option to managing workflows. You can often accomplish the same goals with a select field and some rules. While this approach does give up some of Workflows nice features (like its easy to manage per-transition access controls and a built-in audit trail history), it does the job with considerably less overhead and offers more flexibility in how you work with and display the different workflow states.

Thanks!

EdoP's picture

@Videographics: Excellent! Thank you very much for your swift and elaborate response. I'm getting the hang of this.