This question has been answered by BobRay. See the first response.
[[+pathPrefix]]rest/of/path/to/file.pdf
No, I think that's about as good as you're going to get.
By the way, you can store your files outside of the web root, and static resources can still access them. No need for the htaccess directives.
You can create a media source for the directory, and the static resources will see the media source structure. It won't pick up the media source definiton's path, though, so I use a chunk with the same path as set in the media source, for example '../downloads/', and prefix the path that the static resource does pick up with the chunk:
[[+pathPrefix]]rest/of/path/to/file.pdf
Note that if you're using $modx->resource->get('template'), you'll be getting the template's ID, not its name, but using the ID will be much faster than getting the template object and retrieving its name, which would be the alternative.
Quote from: BobRay at Jul 03, 2013, 07:53 AMNote that if you're using $modx->resource->get('template'), you'll be getting the template's ID, not its name, but using the ID will be much faster than getting the template object and retrieving its name, which would be the alternative.
Awesome Bob - great advice as always. I was retrieving it's name and will adjust to grab id instead. Many thanks!
switch ($modx->resource->get('template')) { case 3: sendTheEmail(); logTheDownload(); break; case 5: sendTheEmail(); break; case '4': logTheDownload(); break; } return '';
Quote from: robcarey at Jul 03, 2013, 02:07 PMQuote from: BobRay at Jul 03, 2013, 07:53 AMNote that if you're using $modx->resource->get('template'), you'll be getting the template's ID, not its name, but using the ID will be much faster than getting the template object and retrieving its name, which would be the alternative.
Awesome Bob - great advice as always. I was retrieving it's name and will adjust to grab id instead. Many thanks!
It sounds like you might possibly be misunderstanding me. I'm suggesting not getting the Template object at all, but rather just testing the ID you get from $modx->resource->get('template'):
(replace the numbers with the actual IDs of the templates)
switch ($modx->resource->get('template')) { case 3: sendTheEmail(); logTheDownload(); break; case 5: sendTheEmail(); break; case '4': logTheDownload(); break; } return '';