Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Last active December 14, 2015 08:49
Show Gist options
  • Save stevewithington/5060602 to your computer and use it in GitHub Desktop.
Save stevewithington/5060602 to your computer and use it in GitHub Desktop.
<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