Posted by Itsme on November 14, 2012 at 1:40pm
Hey developers,
i'm quite new to drupal and the amount of functions and possibilities is overwhelming me.
I have created a custom content type with some fields and i am able to view items with this content type.
I have also created a view for listing all articles of this content type.
But now i want to add some design to those entries and teasers in the view.
What is the best approach for this?
I have found the possibility to add a custom design in node-mycontenttype.tpl.php, but is this really the easiest method?
Thanks in advance
Comments
Styling
You say CCK so I'll assume Drupal 6 but this should work for 7 as well.
To just style, try using a little CSS. Inspect the viewed page to find the id/classes to target.
If you don't want to do theme changes you can alter the HTML outflow via http://drupal.org/project/semantic_cck (6) http://drupal.org/project/semantic_fields (7)
Or you can do it by overriding the field template itself -
In 6 copy content-field.tpl.php from cck's theme folder to your theme folder - this is need to allow for overrides.
Now make a copy of that file and rename to content-field-field_customname.tpl.php
Clear your cache so the template files are recognized.
To verify- add a dummy string 'abc' or whatever to the content-field.tpl.php - you should see it on every field except the one you've overriden. Remember to delete the dummy string but keep that file in your theme folder.
For Drupal 7 it's similar - the template file is located at modules/field/theme/field.tpl.php.
Copy that file, then change that file for all fields, or copy and rename as above to match the field you want to change.
Again, keep that base tpl file in your templates folder or Drupal won't recognize your override template.
Forgot- specifically for a view, you can click on the 'Theme' link in the view to get the name and base code to use for overriding the field in just those instances (see views advanced help pages for more details).
I'm unique, just like everybody else.
If I helped, please pay it forward, backward or sidelong.