Borrowed from the fences project: set the field template on instance level - doesn't add any database tables or so, uses the instance settings which are called anyway every page callback and is cached.
The patch also adds another suggestion after the function, namely the field template itself. Eg, if you chose the minimal template, this would normally call theme_ds_field_minimal() (this can't be changed alas, that's old cruft from the past) but there's not an easy way to override this with a template file. However, the patch adds a new suggestion by stripping of 'theme_ds_field_' and just adding 'minimal' so you can create field--mininal.tpl.php (field.tpl.php must be in your theme directory as well, don't forget that).
So you get this now as suggestions on say for instance a body, first four are core, last 2 from DS.
- field__text_with_summary
- field__body
- field__article
- field__body__article
- theme_ds_field_minimal
- field__minimal <-- in case the tpl file exists, that one is used \o/
So now you should be able todo this:
- enable field templates and select the global default field template
- set the default field template on instance level of a Field API field.
- override the default field template configuration from instance level on view mode level
- or just override the global default template on view mode level per field
Settings this to needs work because
- Need feedback if that last suggestion is ok enough, maybe I should others as well ?
- Needs a lot of testing and also simpletests as wel
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 1299580-2.patch | 3.72 KB | swentel |
| #1 | 1299580.patch | 3.72 KB | swentel |
Comments
Comment #1
swentel commentedAnd the patch
Comment #2
swentel commentedUpdated patch - small bug in suggestion when using overriden field template on view mode level
Comment #3
swentel commentedThis has been committed. Field template can be set on instance level as well.
In case there's another template, these are the suggestions (note, those of field.tpl are removed)
* field--minimal.tpl.php
* field--minimal--body.tpl.php
* field--minimal--article.tpl.php
* field--minimal--body--article.tpl.php
In case you want to add new theming functions, you can implement hook_ds_field_theme_functions_info(). Important is that theme_ds_field_ prefix is used so template suggestions work!
Comment #5
zmove commentedReopen the issue because it seems that you don't have access to the $variable['ds-config'] informations in the field template.
For example I created a field--minimal.tpl.php to theme my fields, but I cannot get access to the "Hide colon" parameter to hide the colon if checked.
Did I miss something ?
Regards,
Alex
Comment #6
swentel commentedComment #7
swentel commentedok, I finally get it, this is actually working as designed, that variable is only available for expert field template.