1

I'm looking to extend the content renderer in a plugin I'm developing so that I can add custom Mura tags to use throughout a website instead of content objects which for the purpose of this plugin are too inflexible.

Firstly, is this the right way to go about it? Am I barking up the wrong tree and there is an easier much more obvious way of doing it without using content objects?

If anyone could help me work this out that would be great.

Dave Mackintosh
  • 2,738
  • 2
  • 31
  • 40
  • Does it *have* to be in a plugin? Cause I think that might be the only thing preventing this from being easy. – Jason Dean Nov 01 '11 at 16:31
  • Yeah it does really have to be a plugin, I mean if its impossible I can live with it being in the content/contentRenderer.cfc or the themes but preferably It'd be as autonomous as possible. – Dave Mackintosh Nov 01 '11 at 16:36
  • The only thing I can this then is to see if your plugins have access to the contentRenderer object through the Mura scope and maybe inject the needed methods into it. This is purely a hypothesis, I have not tested and have no reason to believe it would or would not work. – Jason Dean Nov 01 '11 at 17:00

1 Answers1

4

To add custom mura tags you can use the injectMethod function within your eventhandler.

In the onSiteRequestStart method of your plugins event handler you can use the following function:

<cfset $.getContentRenderer().injectMethod('[mura-tag-key]',[actual-function-to-inject]) />

So if you create a function called getAddress in your event handler you can make it available as a mura tag with the name dspAddress using this code in your onSiteRequestStart:

<cfset $.getContentRenderer().injectMethod('dspAddress',getAddress) />

You can see a real-life example of this in my More dspObjects plugin on GitHub: eventHandler.cfc

Dave Long
  • 9,569
  • 14
  • 59
  • 89