provide a workflow-ng action
fago - December 5, 2007 - 17:40
| Project: | Path Redirect |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
A token enabled workflow-ng action to add path redirects would be awesome. There is already an action for drupal_goto, so probably it wouldn't be hard to build one for path redirects :)
So once could let automatically generate path redirects.

#1
I'm not very familiar with any of the workflow projects, but maybe this is a good excuse to learn. So basically, what we need to do is:
path_redirect_action_infodescribingpath_redirect_action_createor something along those lines.path_redirect_action_create, which would basically just callpath_redirect_savewith appropriate$form_values.Does that sound about right? Does this all just get included in
path_redirect.module, or does it make sense to put it inpath_redirect_workflow.incand only include that if the workflow module is enabled?#2
yep, that sounds right :) The .inc file makes perfectly sense.
You might want to have a look at the drupal_goto action of worklfow-ng: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/workflow_ng...
You could start with that code. This action adds token integration so yours would also benefit from it!
#3
I've started on this, but I'm having a little trouble seeing how the pieces fit together. I'd like to explain a hypothetical use case and see if this is the sort of thing I should expect to be able to do with Path Redirect + Workflow NG. Having a realistic test case will help me get this working correctly.
Say I'm moving a site from a bunch of static HTML pages into Drupal. I don't mind the busy work, so I'm going to recreate all these pages by hand. So what I used to have at:
http://example.com/projects/foo.html...is now going to be at:
http://example.com/projects/fooBut I'd really like to have a URL redirect get created automatically for each of these pages since I don't have access to do this via mod_rewrite. Should I be able to set up a workflow that says:
So the net effect is that I can just go to node/add/page, create my page, and automagically get a path assigned via pathauto and a redirect created via the workflow. That would be nifty. Is that what workflow_ng should let me do?
#4
Here's a very incomplete first stab at it. It does basically work as I'd expect, but I wasn't able to get the above scenario working. I'd end up with
node/add/page.htmlinstead offoo/bar.html. PEBKAC, probably.#5
Here's the configuration I was trying, for what it's worth.
<?phparray (
'cfg_1' =>
array (
'#type' => 'configuration',
'#altered' => false,
'#event' => 'node_insert',
'#label' => 'Redirect page from .html',
'#active' => 0,
'#module' => 'workflow-ng',
0 =>
array (
'#type' => 'action',
'#name' => 'path_redirect_action_create',
'#label' => 'Create URL redirect',
'#settings' =>
array (
'from' => '[node:url].html',
'from_args' =>
array (
0 => 'node',
),
'to' => '[node:url]',
'to_args' =>
array (
0 => 'node',
),
),
),
1 =>
array (
'#type' => 'condition',
'#name' => 'workflow_ng_condition_content_is_type',
'#argument map' =>
array (
'node' => 'node',
),
'#settings' =>
array (
'type' =>
array (
'page' => 'page',
),
),
),
'#name' => 'cfg_1',
),
)
?>
#6
the patch looks good.
@test case: I don't know the token [node:url], what is it about? Probably, it gives you back the wrong value.
-> You could need a token for the path alias of a node, I don't know if this is available somewhere. Instead you could try to rebuild the path with token replacements, however in a real world scenario this might create troubles due to the path cleaning of pathauto/workflow-ng. Anyway, I think a path alias token would make sense and allow both way to work cleanly.
You could also test the correct behavior just with a fixed path redirect string and creating only one node. If that works, it works with token replacements too :)
#7
This version is working pretty well for me. I think you're right, fago; to do what I wanted, I would need a
[node:alias]token which gave me the alias that was being assigned to the node that I'm creating. I may go ahead and commit this...#8
What's keeping you from committing this good patch? :)
#9
Just letting it ripen. :)
I'm marking this fixed. If any bugs are found, new actions or conditions needed, or anything like that, please open a new issue!
#10
Automatically closed -- issue fixed for two weeks with no activity.