Select a taxonomy parent ID based on the current node type for shared field declarations in cck I have a taxonomy vocabulary with the below heirarchy:

*Property Type

 -Commercial
    -Office
    -Building
    -Warehouse
 -Residential
    -Villa
    -Apartment
    -Penthouse


I have two content types for the property information that has a common field called: 'Property Type' relating to that vocab above, again, for the two content types: "Commercial Property" &amp; "Residential Property" they are using the same field declaration that relates to the same vocab group.

I want to use the php advance code to filter 'commercial' and 'residential' whichever content type is concerned. E.g. Villa, Apartment and Penthouse should only show under the "Residential Property" content type.

My Current code is this but it does not work:

if (arg(0) == 'node' &amp;&amp; is_numeric(arg(1))) $nodeid = arg(1);
if($nodeid) $type = noad_load($nodeid);
if($type-&gt;type=='commercial_for_rent' || $type-&gt;type=='commercial_for_sale') return 798;
else if($type-&gt;type=='residential_for_rent' || $type-&gt;type=='residential_for_sale') return 799;


In other words: Show only the sub category items of 'Property Type' vocab (e.g. "Residential terms") if content type being edited is this (e.g. "Residential Property" content type)...

Can someone help me point to the right direction please. 

Thank you!
Apparently, I am answering my own question. This may not be the best solution (the drupal way) but it works and at least for the meantime I can continue the project. Here is how I solved it:

arg(0), arg(1).. will always refer to the current url arguments. so arg(0) will be the first arg after the siteroot, arg(1) is next.. etc..

With my problem, when you are editing a content type here is my current url path for example: http://localhost/mysite/node/add/commercial-for-rent, where arg(0) = node, arg(1)=add etc..

simply posting this to php snippet worked:

if(arg(2)=='commercial-for-rent' || arg(2)=='commercial-for-sale') return 798;
else return 799;

That's at least as far as the url pattern goes. ../node/98/edit is when editing the content which is again this solution will no longer work...

As I said this is not the best solution if there is anyone out there who has better ideas please do tell me so I can edit the snippet and solve this the drupal way.