I have themed my Views. Copied the template into my theme folder. But the problem is all the Views on my site got affected. I only want a certain view to appear differently. How will I rename the template so that it will only affect certain view and not all the Views on my site?

Comments

mooffie’s picture

How will I rename the template so that it will only affect certain view

A view has a name. Say you named you view 'charlee'.

You need to embed this name in the template filename. Say your template file is 'views-view.tpl.php'. You need to rename it to 'views-view--charlee.tpl.php'.

(The naming rules aren't arbitrary. Views UI can help you here: there's a 'Theming information' link in the view's editing screen that lists all possible names for your template files. Each with a different level of specificness.)

hollybeary’s picture

I've also found the views theming wizard to be helpful with theming individual views.

halloffame’s picture

I don't have a theming wizard with Views. It's not in the module page either (to enable). I don't know but does it have to do with the version of Drupal/Views that I'm using? D6.2. Views 2.0-beta3.

This makes me all the more frustrated because all the documentation and tutorials on the site involves theming wizard.

Anyway, I tried renaming the templates as per mooffie's instruction (which what I've been doing anyway). The problem I keep on getting here is that when I rename the template the table/list views disappears.

You see what I'm trying to do here is to put one static image to my custom view so that at least it will look better. I was able to do it perfectly by editing the 'views-view.tpl.php'. However, however... When I rename the php template to 'views-view--mycustomview.tpl.php' (since I only want to do this with a certain view and not all the views on my site) the only thing that appears in the view block is the image and I can't see the view list/table anymore!!!

mooffie’s picture

tried renaming the templates as per mooffie's instruction [...] The problem I keep on getting here is that when I rename the template the table/list views disappears.

Most probabaly because you didn't clear Drupal's cache. You must do that for Drupal to notice the new template file. Drupal keeps looking for the old template file, and since you effectively deleted it, Drupal shows nothing instead.

I don't have a theming wizard with Views.

The Themeing Wizard came with Views 1.x. Themeing is D5 was hard, so an aid was needed. However, since D6 --and Views 2.x-- makes theming so easy, a wizard is not needed.

halloffame’s picture

The problem I was having was with Drupal core. I needed to apply some patch in order to solve my problem.

fgasking’s picture

Hi there,

I'm currently having the same problem, and losing my "view" when I put the relevant template into my template directory.

What patch did you need to apply to get it working?

Many thanks!

halloffame’s picture

This is the patch - http://drupal.org/node/241570

mooffie’s picture

Whatever patch you apply, remember to also clear the theme registry. A feature of mine, that makes life a bit easier, has just been commited to Views. I hope another one gets commited too.

halloffame’s picture

derekwebb1’s picture

Use Active Template. Using Active Template, your template(s) are actually integrated into the view itself. Active Template is similar to ConTemplate except that it applies to views. Active Template also allows you to include JavaScript/jQuery and CSS into your template too. As long as you can use ConTemplate, you can use Active Template.

Active Template is only for D5 at the moment, however if people show interest, we may be inclined to get a version for D6 out soon.

Best regards, Derek
http://collectivecolors.com