I am not particularly new to programming, but trying to theme how Drupal 7 outputs entity fields is giving me headaches. I think Drupal is great, but the documentation could be more organized and complete. I have sifted through a lot of material about this, but I'm still struggling to organize the bits and pieces of information into usable representation of how Drupal 7 treats and outputs field values.
This is an example output that one would like to obtain:
<h1>#field value#</h1> // Suppose this is the node title <h2><a href="">#field value#</a></h2> // Sub-title <div class=""> // Attributes: <div> <h3> #field title#: </h3> #field value# </div> <div> <h3> #field title#: </h3> #field value# </div> <div> <h3> #field title#: </h3> #field value# </div> <div> <h3> #field title#: </h3> <a href="">#field value#</a> // e.g. Link to Taxonomy term page </div> </div>
#field title# and
#field value#, represent where one would like Drupal to output the field titles and/or values submitted when creating entities/nodes.
The idea sounds straight-forward, but I find it to be immensely complicated in practice.
Some pitfalls I have encountered: Drupal makes presumptions, on how the field should be displayed, it gives it additional markup, which I have been unlucky in managing. When outputting through Panels the UI does not provide ways to separate field value and title. Am I under correct impression that I need separate template files or functions for all fields if I want the above structure?
Please shine some light on the matter. I bet many people would love to hear how more experienced developers approach these problems.