views:

32

answers:

1

hi,

I've created several displays for my View.

I thought that I could assign different styles (Gallery, Table, etc) of the view for each display but I realized that only 1 Style is used for all Displays.

The reason I wanted to change is because I'm using DraggableViews, and I would like to keep the same order for all displays, when the user drag some items on the display with draggable nodes.

THanks

+1  A: 

They can.

See http://drupal.org/node/352970

The idea is to use specific names for template files, also called template-suggestions. Some examples are:

The files views-view--alpha--page.tpl.php and views-view--alpha--block.tpl.php, for instance, would control those two types of displays for the alpha view.
The file views-view--page.tpl.php would control all views with a "page" display.
The file views-view--page-1.tpl.php would control the display on the first page of all views (for those that use a pager), while views-view--alpha--page-1.tpl.php would override that display for the alpha view.

If you want more template suggestions, check out the Theme Developer. that resembles somewhat the Firebug, but allows searching for all kinds of template suggestions and theme-function naming documentation; you click on an item in your page and it shows you what names and files to use to override.

http://drupal.org/node/209561

You mentioned a list (unformatted) and a table. You will theme that, using the following files:

  • views-view--list.tpl.php (overrides all lists by any view)
  • views-view--table.tpl.php (overrides all tables by any view)
  • views-view--YourViewName-table.tpl.php overrides the table view for that view.
berkes
hi thanks for links. It is still not clear how to select an "unformatted list" or a "table" style from a template. What I want is to assign different styles to different Views (from drupal back-end this is not possible because they all change).
Patrick
A second question. The theme developer you suggested looks really cool, but it is not ready to download it (red version), are you using it anyway ?
Patrick
Yes, I use it anyway. You should not use -dev versions on a production environment, but you won't run development tools on a production environment anyway.It is a great tool to use locallly while developing.
berkes
And about your problem with the ever changing views-styles: sure, that is what views do. That, is the biggest problem with views in the first place: allows you to change stuff online, but as soon as your theme depends on it, you loose that ability entirely.
berkes
Just to clarify: it is possible to have more than 1 view template for the same type of display if you have 2 different displays in the same view. views-view--admin-content--page.tpl.phpviews-view--admin-content--page-1.tpl.php
mirzu
hi, so the last comment is not clear to me. Can I select the preferred style option (table, gallery, not formatted, etc) for EACH display, from the custom php templates ? (I know I can customize the code for each display, but what I precisely need is to change the parameter specifying the Style) thanks
Patrick

related questions