Customizing Default Output
Recently in the forum someone asked how they could change the default portal output for their news section. I thought I should post my response here to highlight some important information about how to customize Standard Mura output without editing the main display files. This allows developers to upgrade their Mura instances without needin their customizations as well as opens the door for more structured content as well.
There are three ways to change a portals rendering with out touching the main code.
The first way can be done for any display object file in your site's /[siteid]/includes/display_objects/. If you want to customize the rendering for all portals you can do a global reset by copying:
and changing it.
Targeting a Sub Type with an Include
With the second way you can create files that only target a specific type and subtype. First you will need extend the base "Portal" type in your site's class extension manager by creating a subtype named "News" .
Next you need to copy
There you will be able to redefine the markup. Notice the the naming convention for the file.
Using the Local EventHandler.cfc
Finally, the way we tend do it is by creating the same class extensions as in step two but using the local eventHandler.cfc (/[siteid]/includes/eventHandler.cfc). There you can create a method that follows a specific naming convention that will trigger Mura to use it instead of the default code. The naming conventions are:
The methods can directory output the content or return a string.
<!---Direct output---><cffunction name="onPortalNewsBodyRender" output="true" returntype="void"><cfargument name="event"><cfset var content=event.getContentBean()><cfoutput><!--- The setDynamicContent() method is what executes the [mura] tag --->#event.getContentRenderer().setDynamicContent(content.getBody())#<!---You can create structured out put with Custom attribute--->#content.getValue('customVar')#</cfoutput></cffunction><!--- Returns a String---><cffunction name="onPortalNewsBodyRender" output="false" returntype="String"><cfargument name="event"><cfreturn event.getContentRenderer().setDynamicContent(event.getContentBean().getBody()) /></cffunction>
The benefit of this approach is that you can later take this method and register it as a plugin if you want to redistribute it over and over.
Anyway, I thought this info might be of use to some people. Please feel free to post your thoughts.