How to detect when a user navigates to a taxonomy term page and access that terms data? I'm making a custom directory navigation using the PHP code filter, and putting the code in a block. I need to detect when a user navigates to a taxonomy term page, and extract data related to the term so I can display the children of that term, just like a web directory.
Since there is no global variable that you could use to load the node, you will have to use code like the following:

&lt;?php
if ( arg(0) == 'node' &amp;&amp; is_numeric(arg(1)) &amp;&amp; ! arg(2) ) {
$node = node_load(arg(1));
}
dsm(get_defined_vars());
?&gt;


The dsm(get_defined_vars()); part is of course optional and will only work if you have the devel module enabled. However, if you do have devel, you will be able to see the whole $node object and the tags associated with the specific node.

Notice, that if you are in a term page, you can use the same principle to load a specific term. For example:

&lt;?php
if ( arg(0) == 'tag' &amp;&amp; is_numeric(arg(1)) &amp;&amp; ! arg(2) ) {
$term = taxonomy_term_load(arg(1));
}
dsm(get_defined_vars());
?&gt;