Last active
August 29, 2015 14:08
-
-
Save ronnieduke/c7fc1dc83222f1677580 to your computer and use it in GitHub Desktop.
Render Mura Extended Attributes yourself. This is useful when wanting to use custom javascript or design to enhance the UX of your extended attributes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- Drop this into your site or theme eventHandler.cfc ---> | |
<cffunction name="onContentTabBasicBottomRender"> | |
<cfset subType = application.configBean.getClassExtensionManager().getSubTypeByName("Folder","Blog", $.event('siteID'))> | |
<cfset extendSets = subType.getExtendSets(inherit=true,container='Custom',activeOnly=true)> | |
<cfoutput> | |
<!--- Loop through the extend sets ---> | |
<cfloop from="1" to="#arrayLen(extendSets)#" index="s"> | |
<cfset extendSetBean=extendSets[s]/> | |
<cfset style=extendSetBean.getStyle()/> | |
<div class="fieldset"> | |
<h2>#HTMLEditFormat(extendSetBean.getName())#</h2> | |
<cfsilent> | |
<cfset attributesArray=extendSetBean.getAttributes() /> | |
</cfsilent> | |
<!--- Loop through the attributes ---> | |
<cfloop from="1" to="#arrayLen(attributesArray)#" index="a"> | |
<cfset attributeBean=attributesArray[a]/> | |
<cfset attributeValue=$.event('contentBean').getvalue(attributeBean.getName(),'useMuraDefault') /> | |
<cfif not attributeBean.getType() eq "hidden"> | |
<div class="control-group"> | |
<label class="control-label"> | |
<!--- If the attribute has a hint, display it ---> | |
<cfif len(attributeBean.getHint())> | |
<a href="##" rel="tooltip" title="#HTMLEditFormat(attributeBean.gethint())#"> | |
#attributeBean.getLabel()# <i class="icon-question-sign"></i> | |
</a> | |
<cfelse> | |
#attributeBean.getLabel()# | |
</cfif> | |
<!--- If the attribute is a file, display file stuff ---> | |
<cfif attributeBean.getType() eq "File" and len(attributeValue) and attributeValue neq 'useMuraDefault'> | |
<cfif listFindNoCase("png,jpg,jpeg",application.serviceFactory.getBean("fileManager").readMeta(attributeValue).fileExt)> | |
<a href="./index.cfm?muraAction=cArch.imagedetails&contenthistid=#$.event('contentBean').getContentHistID()#&siteid=#$.event('contentBean').getSiteID()#&fileid=#attributeValue#"><img id="assocImage" src="#application.configBean.getContext()#/tasks/render/small/index.cfm?fileid=#attributeValue#&cacheID=#createUUID()#" /></a> | |
</cfif> | |
<a href="#application.configBean.getContext()#/tasks/render/file/?fileID=#attributeValue#" target="_blank"><i class="icon-download"></i> Download</a> <input type="checkbox" value="true" name="extDelete#attributeBean.getAttributeID()#"/> Delete | |
</cfif> | |
</label> | |
<div class="controls"> | |
<!--- | |
<cfif attributeBean.getName() eq "[Some Extended Attribute Name]"> | |
<cfinclude template="some-custom -file.cfm"> | |
<cfelse> | |
---> | |
#attributeBean.renderAttribute(attributeValue)# | |
<!--- </cfif> ---> | |
</div> | |
</div> | |
<!--- end control-group ---> | |
<cfelse> | |
#attributeBean.renderAttribute(attributeValue)# | |
</cfif> | |
</cfloop> | |
<!--- end attribute loop ---> | |
</div> | |
</cfloop> | |
<!--- end extend set loop ---> | |
<!--- Custom Javascript ---> | |
<script src="#$.siteConfig('themeAssetPath')#/js/extendScripts.js"></script> | |
<!--- Example javascript to hide/show an attribute based on another attributes selection ---> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
if ($('##extAttribute1').val() == 'someValue'){ | |
//Get the dependent attribute's parent container and hide it | |
$('##dependentAttribute').parent().parent().hide(); | |
} | |
$('##extAttribute1').on("change", function(){ | |
var value=$(this).val(); | |
// if the extAttribute1 value makes the dependentAttribute irrelevant, hide it | |
if (value == 'someValue'){ | |
$('##dependentAttribute').parent().parent().fadeOut("slow"); | |
}else{ | |
$('##dependentAttribute').parent().parent().fadeIn("slow"); | |
} | |
}); | |
}); | |
</script> | |
</cfoutput> | |
</cffunction> | |
</cfcomponent> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment