Add a variable to custom views template
I haven't time to actually investigate the details of this right now, but if you enable the devel module, put

&lt;?php dpm(get_defined_vars()); ?&gt;


somewhere in your template file somewhere, and then refresh the page twice you will get a list of available variables which you can then click on to expand and drill down into the arrays and objects.

If you still cannot find the tid anywhere to use, try adding the tid as a hidden field to your view, then it will definitely be in there somewhere for you to use.