views:

1921

answers:

6

I'm trying to theme a single "display" in a view. What I'm trying to achieve is to have some control over how the row is rendered (eg. print the fields in the row, and maybe add some text in between. along with some divs for styling purpose). I've looked for days for the template to edit. I've used even the Theme Developer and the View's Theme Information, but no luck. All

My view's name is Calendar, and there are a bunch of displays. Could anyone tell me what I should do in order to customize the rows in this particular display? Does drupal even provide this flexibility?

The Name and Title of my display in the Calendar view is:

Name: List view
Title: List

Here's the theme information for row style:

Row style output: views-view-fields.tpl.php, views-view-fields--calendar.tpl.php, views-view-fields--page.tpl.php, views-view-fields--calendar--page.tpl.php, views-view-fields--calendar.tpl.php, views-view-fields--page-1.tpl.php, views-view-fields--calendar--page-1.tpl.php

Could someone tell me how to


Edit:
(Some additional information the OP posted in an answer)

I'm using Drupal 6. I'm not sure what page-1 indicates here The following is the list of display I have in this view:

Defaults 
Calendar page 
Calendar block 
Month view 
Week view 
Block view 
Upcoming 
List view 
Ongoing Block Feed

As you see, none of which has the string "page-1". I edited views-view-list.tpl.php, one of the file listed for "style output". The only variable I have access to is rows, which is an array containing all individual rendered "row". Like I mentioned before, the rows are generated somewhere else, and already contain the rendered fields. How can I customize these rows?

A: 

Have you added the custom code needed in the template.php file? I know in drupal 5 you need to put code in 3 files:

template.php views-views-fields--[name].tpl.php views-views-fields--[name].css

Also you might try: http://drupal.org/node/128741

lilott8
+5  A: 

You shouldn't have to add anything to template.php if you are using Drupal 6.

The list of possible theme files that you have there goes in order from least to most specific. For instance, the first one, views-view-fields.tpl.php, will apply to all fields of all views on your site. The last one, views-view-fields--calendar--page-1.tpl.php, will only apply to the "page 1" display of the "calendar" view, so I'm guessing that's the one you want to overwrite.

When you click on Theme Information in the view, the display provided ("page 1" or whatever) applies to the display you are currently on. So if you want to theme fields in a certain display (the "blocky block" display of the "calendar" view, for instance), then you would click the "blocky block" display in the vertical menu on the left, then click Theme Information for that display.

So once you figure out which one you want to use, make a new file in your theme directory with that name, then copy of the contents of the current theme file (click the name of the theme files section on the Theme Information page) into your new theme file, then edit away. Remember, if you overwrite a theme file, you have to click "Rescan template files" in the Theme Information page for the new file to take effect.

Hope that helps!

theunraveler
not to say 'try reading the hints views ui is displaying'.sorry, i don't want to sound harsh, but it is pretty self-explanatory.
barraponto
Agreed. Nothing wrong with reiterating, though. And the Views documentation is sort of notoriously obtuse anyway.
theunraveler
A: 

I'm using Drupal 6 I'm not sure what page-1 indicates here The following is the list of display I have in this view:

Defaults 
Calendar page 
Calendar block 
Month view 
Week view 
Block view 
Upcoming 
List view 
Ongoing Block Feed

As you see, none of which has the string "page-1". I edited views-view-list.tpl.php, one of the file listed for "style output". The only variable I have access to is rows, which is an array containing all individual rendered "row". Like I mentioned before, the rows are generated somewhere else, and already contain the rendered fields. How can I customize these rows?

Ronald
You should not put explanations/additions to your question into an answer like this - edit your question instead. This is not a typical thread, and the order will get changed as people vote on answers, so any additions you put in here will be hard to find sooner or later.
Henrik Opel
+1  A: 

The displays have custom names on the surface only, but internally they are referenced by id. 'page_1' will be your first display of type 'page' (blocks will become 'block_[id]', feeds will become 'feed_[id]' and so on).

So if you posted your displays in order, 'page_1' would be the 'Calendar' display. You can check this by looking at the links under the display entries in the display listing on the right of the views config page. They will have anchors named '#views-tab-page_1', '#views-tab-block_1' and so on.

As for overriding the templates, be aware that if you add a new *.tpl.php file, you need to reset the theme registry for it to be 'picked up' by Drupal.

Henrik Opel
A: 

i have the same problem: what function handles $row so that we can modify the variable before we render styles in it?

var_dump( $row );

only displays the row as string as if some function has already processed the array and only gives us the string

Harvey
A: 

answering the second question: the style output is not the template you're looking for. row style is the template that edits how fields are arranged within the row. if you want to edit how a particular field outputs its content, then the specific field template should be edited.

barraponto

related questions