Question

I am trying to create a new .tpl.php for some of my views. I know how to create the file and display the elements the way I want, but only by changing the default views-view.tpl.php which would change the way all my views are displayed.

Supposedly I should be creating a new file by looking at Theme: Information and giving it one of the names available that would be something like: views-view--VIEW-NAME.tpl.php, but when I do this and leave the file in the theme folder in the views module and press "Rescan template files" it doesn't detect it.

Should I put the file in a different location?

FYI: What I am trying to do is place my views content inside a fieldset, something like this:

<fieldset class="fieldset collapsible form-wrapper"
 <legend>
   <span class="fieldset-legend">
     <a class="fieldset-title">
       <?php print $header;?>
     </a>
   </span>
 </legend>
 <div class="fieldset-wrapper">
    <?php if ($rows): ?>
        <div class="view-content">
          <?php print $rows; ?>
        </div>
    <?php elseif ($empty): ?>
        <div class="view-empty">
            <?php print $empty; ?>
        </div>
    <?php endif; ?>

    <?php if ($pager): ?>
        <?php print $pager; ?>
    <?php endif; ?>    

 </div>

As I said this is working, I am just trying to put it in a different .tpl.php file and apply it only to certain views. Also if there is an easy way of making the fieldset collapsible that would be useful, although not essential.

Was it helpful?

Solution

Put the template file in your themes directory not views theme directory. It will detect it there. I like to have a views directory inside the themes template directory to organize view template files. I mimic views naming convention for a directory structure so views-view-fields--brands--default.tpl.php and views-view-grid--brands--default.tpl.php would go in:

views/brands/default

It's a nice way to keep the files organized.

OTHER TIPS

Drupal 6 has Viewfield (http://drupal.org/project/viewfield). I think this would help you with what you want to do. There is a issue with discussion of porting to D7 and somebody has even released an initial D7 port that you could try out. See that queue here: http://drupal.org/node/704014

It allows you to setup views with a content type and define what params you want to allow the user to control or if you want them to do anything at all with the view.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top