Quote from: BobRay at Jun 20, 2014, 02:23 PMThis would be infinitely faster than your conditional and possibly easier to maintain:
/* SelectChunk snippet */
$id = $modx->resource->get('id');
switch ($id) {
case 1:
$chunk = 'myChunk1'
break;
case 2:
$chunk = 'myChunk2'
break;
case 3:
$chunk = 'myChunk3'
break;
case 5:
case 11:
$chunk = 'myChunk4'
break;
default:
$chunk = 'myChunk?"
}
return $modx->getChunk($chunk);
Awesome. If I pull this off, it'll be my first snippet (though not really, I suppose). I'll give it a shot!
Quote from: BobRay at Jun 20, 2014, 02:23 PMYou could make it a little faster yet by naming the chunks with the IDs (with a duplicate for # 11) and just doing this:
This has been implemented -- thanks.
About getResources (good questions):
1. Is the order of the properties tweakable to further aid optimization?
No, it won't make any measurable difference.
2. Would a property set speed processing, or is this solely a dev efficiency?
No, it would slow things down slightly.
3. Does specifying the template, when applicable, help limit the processing (assume yes, but worth asking)?
Yes, if it reduces the number of resources retrieved, especially when TVs are involved.
4. The site is flat, with a max depth of 1. In this scenario, does specifying depth aid processing speed, or is that case only when depth exceeds more than one level?
It shouldn't make any appreciable difference.
All that said, the things you're contemplating are pretty trivial compared to the inherent sluggishness of using getResources with TVfilters. For a small site, it won't make too much difference, but if the site will grow, you can speed things up by an order of magnitude by ditching the TVs, extending modResource, and moving the data to a custom DB table.
More information here: http://bobsguides.com/blog.html/2014/06/02/why-extend-modresource/ and here:
I will read this, for sure. This probably exceeding my skill level...but I have a photography website that could benefit from this, so I'll dig in...
And, to your follow-up question -- it's not just "content", per se. It's everything that makes each the page unique -- sections, subsections, etc. Given this, would the content field still be a better approach?