I did all the searches I could think of in the core code (even the 198 non-case-sensitive places where 'templatevarresource' appears and the 268 places where 'template' appears) and couldn't find where MODX actually gets the template.
This is from my book, but I doubt if it will help:
OnHandleRequest — Fires when any request for a resource is received in the front end.
OnWebPageInit — Fires after determination that the site is online and the requested resource is located.
OnLoadWebDocument — Fires after the requested resource is loaded, but before it is parsed.
OnParseDocument — Fires just before the MODX tags are processed.
OnWebPagePrerender — Fires just before a completed web page in the front end is sent to the browser, after all tags have been processed.
The only thing I can think of is to put $modx->resource->set('template', $id) in all of the above, one at a time, and see where it has any effect.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html