Closed (fixed)
Project:
Semantic CCK
Version:
6.x-1.x-dev
Component:
Code
Priority:
Minor
Category:
Task
Assigned:
Reporter:
Created:
23 Sep 2010 at 20:17 UTC
Updated:
23 May 2011 at 07:22 UTC
There are a whole lot of variables available in the .tpl.php file, and explicitly printing each (as is the case now) makes the template file pretty messy.
I don't know if it is possible, but it would be nice if both the logic and the number of necessary PHP variables to print could be reduced by moving some processing to the semantic_cck_preprocess_content_field function.
Just a thought. :-)
Comments
Comment #1
rjay commentedI agree that logic should always be placed in a preprocess function, and I believe we've done that as much as possible in Semantic CCK. The current contents of the semantic content field .tpl are essentially the same as the normal field content field .tpl, with hard-coded div/label tags replaced by variables.
The only other logic we've added is
ifstatements to determine if variables are empty or not before printing them, which I believe is acceptable in a template file. Reducing the number ofifstatements is probably the only modification I'd attempt to make.Did you have any suggestions as to what specifically you would move to the semantic field preprocess function? I'm willing to consider modifications to the semantic content field .tpl as long as we don't restrict the amount of freedom themers have if they choose to override it.
Ryan
Comment #2
itangalo commentedHm, I see your point. There really aren't that many places where the code could be shortened.
However, here is one suggestion:
could be changed to just
if ($label_display == 'above') : print $label;if the $label variable is set to conatain all of the variables and markup above. (The individual elements could still be available in the tpl.php if anyone would like to use them explicitly.)It becomes more tricky with the inline labels, since they could be repeated for multiple-value fields. *Maybe* $label could be used as an array, with one value per field instance. But I don't know what consequences that might have when preparing the variable.
If it is too complex to use a $label variable for multiple-value fields, it doesn't really make sense to use it for labels above the field. So maybe this whole issue is more or less pointless. :-/
I'll give it some more thought, and if I come up with something smart I'll write a line or two.
Cheers!
Comment #3
rjay commentedComment #4
rjay commentedI've reduced the amount of whitespace in the template file and used the drupal_attributes() function on the field label to reduce the amount of logic in the template file a bit. These changes are committed and are included in version 6.x-1.4.