By Karlheinz on
Hey there.
I know there's probably a simple answer for this, but I didn't find it by searching the site.
I've got a custom CCK Text field ("tracks") with multiple values. How do I get this to display as an ordered list?
I can get the class styles, and set the display attribute to "list-item," but if I try to set the list-style to "decimal" then all I get are zeros.
I would try to override one of the template files, but I don't know how to do that for only a specific CCK field.
Comments
Aha
I found the answer. It was actually in the Advanced Help files for CCK, but not on this site. (The handbook pages should probably be updated...)
The answer is to copy this:
sites/all/modules/cck/theme/content-field.tpl.php
...to your theme directory. Next, make another copy of it, except name it:
content-field-FIELD_NAME.tpl.php
...where FIELD_NAME is the machine-readable field name (usually starting with "field_", so in my case the file is called content-field-field_tracks.tpl.php). Now, edit away.
You need to rebuild the theme registry before you see any effect. Also, you need to make sure you still have content-field.tpl.php in your theme directory, whether or not you edit it.
In my case, I just substituted this line:
<div class="field field-type-<?php print $field_type_css ?> field-<?php print $field_name_css ?>">...with this one:
<ol class="field field-type-<?php print $field_type_css ?> field-<?php print $field_name_css ?>">...and this line:
<div class="field-item <?php print ($count % 2 ? 'odd' : 'even') ?>">...with this one:
<li class="field-item <?php print ($count % 2 ? 'odd' : 'even') ?>">Plus I changed the matching closing tags.
Works like a charm.
-Karlheinz
Thanks
Thanks I did this and it worked well.
Best
Works as it should
Like a charm. Thanks.
Great idea! Works perfectly.
Great idea!
Works perfectly. Now I need to figure out how I can style this for pretty looks ;)
A simpler way to solve the
A simpler way to solve the list/etc. formatting issue is to use the Text Formatter module instead; no template file changes needed :)
__________________
Personal site: www.jeffgeerling.com