EasyEdit API: Getting the metadata field that spawned the Asset Finder


(Birdg) #1

Hi,

 

I am trying to write a small Edit+ plugin that restricts the Asset Finder to a certain folder depending on the field that spawned the Asset Finder. For example, I want Edit+ users to be prompted to choose from a "Calls to action" folder if they are choosing a related asset for the Call to action metadata field.

 

What I can't work out is how to grab the ID of the "calling" metadata field once the Asset Finder is open. Has anyone done this or got any tips?

 

Thanks,

 

Graham


(Tom Chadwin) #2

Pseudo-suggestions:

 

-  does window.opener.document.activeElement get you anywhere?

 

- alternatively, hack the button which opens the asset finder to add in an extra querystring var which you can then pick up in the asset finder itself

 

Others will almost certainly have better ways to do this.

 

Tom


(Scott Hall) #3

Maybe approach from a different angle? Could use http://manuals.matrix.squizsuite.net/ees/chapters/asset-finder#Customisable-Root-Nodes to have it there all the time. And then use  AssetFinderBeforeInit in plugin to assess conditions and then do something e.g. add class to body tag and go from there. Just an idea, could completely off depending on what you're trying to accomplish.