Okay, I have got the schema working now, but I still have problems with getting the right tiles (this is probably due though to exotic custom Projection and wrong BBOX origins on my end, another problem I am working on).
As suggested, I am using the functional tilelayer plugin. The zeroPad() function just pads with zeros the tile references:
function zeroPad(num, places) {
var zero = places - num.toString().length + 1;
return (Array(+(zero > 0 && zero)).join("0") + num).toString().slice(-places);
};
var funcLayer = new L.TileLayer.Functional(function (view) {
xPadded = zeroPad(view.tile.column,9);
yPadded = zeroPad(view.tile.row,9);
zPadded = zeroPad(view.zoom,2);
var url = "http://tile{s}.domain.com/topo/{z}/{c1}/{c2}/{c3}/{r1}/{r2}/{r3}.png"
.replace('{s}', view.subdomain)
.replace('{z}', zPadded)
.replace('{c1}', xPadded.slice(0,3))
.replace('{c2}', xPadded.slice(3,6))
.replace('{c3}', xPadded.slice(6,9))
.replace('{r1}', yPadded.slice(0,3))
.replace('{r2}', yPadded.slice(3,6))
.replace('{r3}', yPadded.slice(6,9))
;
return url;
}, {
tms: true, //Optional depends on your tiling schema
subdomains: '1234'});