By enchance on
Is it possible to add conditionals inside .tpl.php files? For example, if I put a conditional in field.tpl.php, it will check for the field name which is trying to access it (e.g. 'field_foo'). That way instead of making multiple field--['field_name'].tpl.php files, all I need is just one (field.tpl.php).
Another way you can look at it is "How do I get the name of the page/region/node/field which is trying to access this .tpl.php file?"
Comments
.~.
I think you can use them.
refer to http://api.drupal.org/api/drupal/modules--field--theme--field.tpl.php/7 for avliable variables so that they can be used in conditions.Not sure though.feel free to correct me if i am wrong.
It worked!
hehehe... *cue thunder*
Now I can consolidate all my template files into one primary file giving me more control since everything is in code instead of in files.
For reference, here's a sample code to see how you can use it in your themes:
.~.
or you can even use
glad it helped.
Install the Theme Developer
Install the Theme Developer module, it will be your best friend...
http://drupal.org/project/devel_themer
--
Read more at iRolo.net