Jump to content

"cascading" workflow


Recommended Posts

Hi,

 

I've created a few simple workflows in the past, including ones that call Python scripts in the background.

 

However, what I can't seem to find is how to create a "cascading" workflow. Here's an example:

 

  1. Call the workflow using a keyword
  2. The workflow returns a list of items
  3. The user selects one of the choices
  4. The workflow now returns a new list of items based on the user's choice in [3]
  5. etc…

This would go on until the choice selected by the user is an endpoint, which would then be passed on to the output action.

 

The script filter seems like it could do this, and I've looked at the example workflow in Alfred. However, I don't get how I could implement showing a new list after the user has selected an item.

 

One of the things I had in my for this, is a certain website's sitemap that I use frequently. By implementing it's menu in a workflow, I would navigate through the menu in Alfred and then call up the correct page all from the same workflow. The complication is that the depth (number of times you'd iterate until you hit an endpoint) is dependent on the selection.

 

The functionality resembles the first few steps of the workflow created for The Pirate Bay (demo here), where you go from Video to HD TV Shows and so on. I looked at the code but it's a bit much to wrap my head around (seems to spawn a local web server to call PHP code).

 

I hope I've been able to clarify what I'm after. Any pointers, suggestions, … would be very welcome. Thank you!

Link to comment

Look at the first pinned item in this forum to see a thread about how to do this.

 

The concept is actually pretty simple once you break it down:

 

Pick a "separator" character, something unique like "|" or ">" or " > " (it can be a string).

 

Then, when the script filter runs, break apart the string based on the separator. So, if you chose ">", then the query:

"first option>second option" 

would break into

(1) first option
(2) second option

Next, make sure that you set the option to be invalid and have no argument. If it's valid or has an argument, then pressing enter on it will cause Alfred to pass the argument (or null) through to the next workflow object (or to /dev/null). Have the autocomplete field be the full option.

 

So, if the user types "keyword fir", you would filter against an array (or dictionary) of possible "first-level" options and display only what is needed. There would be an xml entry for "first option" that would be invalid with no argument and have the auto-complete set to "first option".

 

The same goes for "second option". Invalid, no argument, autocomplete "first option > second option".

 

Dean's Python Alfred Workflows library takes care of the filtering and all the hard stuff for you. Use that one.

Link to comment
  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...