extend contentRenderer Mura

526 views Asked by At

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.

1

There are 1 answers

3
Dave Long On BEST ANSWER

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