By bkosborne on
So I'm diving into the views module and have some questions for styles...
If I use a template file for my view, is there any point at all to messing around with the styles options (Style and Row Style I mean)? Do they conflict with one another?
My current understanding is that using the style settings in the view module allows you to sort of customize the existing styles that are used within drupal... However if you just go ahead and create a template file with the name of the node or whatever, it will override all of these options anyway?
Really my true question is how do template files and views interact? I am completely lost in this regard. Thanks.
Comments
The views module uses...
The views module uses its own template files for generating the html, if that is what you're asking.
If your objective is to style the generated views with your own custom 'look & feel', views provides its html output with lots of id's and classes just for doing that!
Template Files Everywhere
The "Style" and "Row Style" in Views are extremely important, and have less to do with the templates you use (though they do affect that), and more to do with the overall format and amount of content you're going for. If you have tabular data, for example, you should use a Style of 'Table'; if you want things to show up in nice rows and columns (but not be a table), use 'Grid'. If you want to pull whole nodes as values, make the Row Style 'Node', otherwise make it 'Fields' and pick specific fields you want to pull.
The Style grows even more important when you install auxiliary modules that leverage the main Views module. For example, if you install Views Bulk Operations or Draggable Views, you get a whole new Style with different options and features. Try it out.
In regards to template files, if you click the "Theme: Information" link, you see a list of all the possible templates you could use to affect the way your Views results are printed. They are listed in the order of big picture to small picture, i.e. templates that affect the whole View to templates that affect the smallest parts of your Views results. The names should somewhat speak for themselves, as to what they affect.
When looking at the templates, though, you probably want to know what the default templates look like. Go into the Views module itself and then into the 'theme' folder to see all the default Views templates. When creating a template of your own, choose the default template (usually shows up in bold in the Views UI for the level of granularity you want), copy the code, place it in your new template and start chopping away.
As you mention, if you're using 'Node' as the Row Style, then yes, custom templates you use for nodes will affect the Views output, because Views respects Drupal's node and theming systems. If you want more control, you can use the 'Fields' Row Style and then do custom theming for the fields in the Views result, and leave your node templates untouched.
So, summations: Views uses its own templates to render results. Views lets you override those templates at various levels of granularity. Copy and paste from default Views templates to start off your custom ones. If you're Row Style is 'Node', Views respects the node system's theming for the node content.
Happy theming!
Exactly what I wanted to know
Exactly what I wanted to know - thanks so much for clearing this up.