Skip to main content

Not so damned DAM handlers

Posted by rah003 on January 22, 2010 at 5:46 AM PST

I was asked  recently if/how can someone create or configure the link control in Magnolia dialog so it would allow editor to choose not only the target of the link, but also the repository from which to choose such target.

For those not familiar with the link control, right now you have to configure repository from which the control will let you select the target in the dialog definition. More details on controls are here

My first response to the question was along the lines of "well, if you want to choose dynamically, just extend the existing control and make it offer the selection". 

But just a minute later I got an idea ... what if, there was a way to create such dynamic control already. 

In Magnolia 4.1, we have introduced a dynamic DAM handlers. Those handlers  let you choose the source for the asset to be displayed in a page. And isn't the target for the link is just another sort of an asset? Ultimately, you can argue that, but as far as handlers are concerned it doesn't really matter. Plus, we already have a handler that let one choose the resource from the repository - the DMS DAM handler. From there it was only a minute to find out that I can indeed reconfigure the handler to point to any repository and start at any given path. 

Granted that handling of the link in the template is a bit more complicated with this solution then using the simple link control, but ultimately it is also much more powerful and with power comes the responsibility. The only missing point now is to rename DmsDamHandler to RepoAssetHandler :D

As mentioned above, one might want to argue whether this is not an abuse of the DAM handlers and whether such a solution is not too heavy weight. Alternative would be to use something similar to link selection offered in FCKEditor control, but that would definitively require additional development. The solution above works as is.