Applying one Action from another

I’m developing an Action for a Freeway user and need to replicate part of the functionality of another Action. Rather than forking this code and having two Actions to maintain I was wondering if there was any way of programatically applying one Action to an item from another Action.

I’m aware that I can have my Action use the functions and methods contained within another Action applied to the site but I don’t know if I can so this without it first being applied.

Ideally what I’d want is to;

  1. Search for the other Action
  2. If located then offer the UI to the user to use the functions contained within that Action
  3. On publish call the functions and libraries within this Action to do our stuff.

If the Action isn’t installed then the UI would be disabled.

I guess what I’m looking for is a way to set an action-include control programatically.

Any ideas are welcome as I really don’t want to have to fork this Action if I can at all help it.
Regards,
Tim.

FreewayActions.com - Freeware and commercial Actions for Freeway Express & Pro - http://www.freewayactions.com


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Tim

Are you trying to adjust the (B) action if the (A) hasn’t been applied to an actual folder, page or item?

Or are you trying to adjust the (B) action one way or another if the (A) action doesn’t exists within the freeway application?

If its the first would what Joe pointed out to me about the google maps actions be usable in some way.

http://www.freewaytalk.net/thread/view/114874

If its of any help this is how I used it in conjunction with your root path example I hope its of some use
this is how I used it:

function fwBeforeStartHTML(){ 

	//Look for the same checkbox in an other Action in the document
	//If it exsists, use it in this Action
	var myAction = (fwDocument.fwPages.fwFindAllActions( "WebYep:   1 - Config-File Creator" , true ));

	///////////////////////  if other action existis and checkbox is on	
	if (myAction.length>1);
	{
	//get the root folder directly from Tims example
	var root = fwDocument.fwPages.fwItems[0].fwFolder;
	//get the relative path to the root folder from the current page 
	var path = root.fwHttpPath(fwPage);
	
	var HTMLTag = fwDocument.fwTags;
		for (i in myAction)
			if (myAction[i].fwParameters["SL"].fwBoolValue)
			HTMLTag.fwAddRaw(fwMarkups['initSL'] + """ + path + "slpw/sitelokpw.php") ?>" + fwMarkups['init']);
	//alert ("HOORAY some extra code");
	}

actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Max,
Thanks for the reply.

On 7 Sep 2012, at 11:21, max wrote:

Are you trying to adjust the (B) action if the (A) hasn’t been applied to an actual folder, page or item?

Or are you trying to adjust the (B) action one way or another if the (A) action doesn’t exists within the freeway application?

More the first option really. Here’s an example;

  1. New Action needs to encode links using the Anti Spam functions
  2. If the Anti Spam Action is applied to the site I can use fwFindAllActions to control it and do my stuff
  3. If the Anti Spam Action isn’t applied then fwFindAllActions won’t work as it is only searching the document object

I can use fwFindFile to locate the Anti Spam Action in the Finder and can even read in its code using fwOpenRead but can’t see how I could apply or link to its functions from within my new Action.

I suspect it isn’t possible but it would be very powerful to be able to do this as more and more of Actions I create tend to be built on elements I’ve already created in other projects.
Regards,
Tim.

FreewayStyle.com - Free Freeway templates and parts to download, use and explore - http://www.freewaystyle.com


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Applying an Action to an item programmatically can’t be done, but you can use a src attribute on the action-javascript element. This allows you to include libraries of reusable JavaScript in one or all of your Actions. Here’s the usage:

<action-javascript src="library.js" />

The JavaScript file would structurally be the same as any regular JavaScript file you were attaching to an HTML page.

Hope this helps,
Joe


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks Joe. I’ll have a play with that but I think it may not provide me with the flexibility I need.
Regards,
Tim.

On 7 Sep 2012, at 11:53, Joe Billings wrote:

The JavaScript file would structurally be the same as any regular JavaScript file you were attaching to an HTML page.


Experienced Freeway designer for hire - http://www.freewayactions.com


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Joe,
I can’t seem to get this to work. Do you have an example I can see please?

I also tried a remote path (http) to the src file in the hope that I could maintain a centralised Action on a public server but, alas, Freeway didn’t like that. It’s a shame as it would have allowed me to update one file knowing that all of the Actions that use it would also get updated. Powerful, a bit scary, but very useful.
Thanks,
Tim.

On 7 Sep 2012, at 11:53, Joe Billings wrote:

you can use a src attribute on the action-javascript element


FreewayActions.com - Freeware and commercial Actions for Freeway Express & Pro - http://www.freewayactions.com


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options