3

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.

3

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.

  • great! that worked perfectly. do you mean u create folders inside your current theme for ur views templates? because I tried doing that and it didnt find the file. Thanks – Perbert Mar 21 '11 at 16:25
  • 1
    yes in your current theme. did you rescan the template files after putting them into directories? – Jepedo Mar 21 '11 at 17:21
3

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.

  • thanks, this sounds useful and easy to use, could probably use it and place it inside a fieldgroup to achieve what I want but for now Im sticking with the template files since they allow more flexibility – Perbert Mar 21 '11 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.