Last active
December 14, 2015 08:49
-
-
Save stevewithington/5060602 to your computer and use it in GitHub Desktop.
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
<cfcomponent extends="mura.content.contentRenderer"> | |
<!--- | |
Add this method to the contentRendrer.cfc of any Site you wish to HAVE the SiteID in the URL. | |
Also refer to https://gist.github.com/stevewithington/5060589 for rewrite rules needed!! | |
---> | |
<cfscript> | |
// Drop these methods into your Site's contentRenderer.cfc for the sites that you WANT SiteIDs in URL | |
public string function getURLStem(required siteid, filename='') { | |
var sid = '/' & arguments.siteid; | |
var fname = getCleanFilename(arguments.filename); | |
// you want to make it so that it **always** adds in the SiteID | |
return !Len(fname) ? | |
sid & '/' : | |
application.configBean.getIndexFileInURLs() ? | |
sid & '/index.cfm' & fname : | |
sid & fname; | |
} | |
private string function getCleanFilename(filename='') { | |
var fn = arguments.filename; | |
if ( Len(fn) ) { | |
if ( Left(fn, 1) != '/' ) { | |
fn = '/' & fn; | |
} | |
if ( Right(fn, 1) != '/' ) { | |
fn = fn & '/'; | |
} | |
} | |
return fn; | |
} | |
</cfscript> | |
</cfcomponent> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment