2

This is hard to explain so I'm attaching an image.

When someone clicks on a filter to search for something, I would like the resulting page to show results but not the filter. Maybe simply a link like "back to search".

Or possibly a small search box, like basic search but not every filter.

enter image description here

3
  • Are you using D7 or D6?
    – Bala
    Commented May 18, 2013 at 12:33
  • check this drupal.org/node/1100550
    – Bala
    Commented May 18, 2013 at 13:03
  • I'm using drupal 7. But I can't figure it out still, this is what I did: 1. add a view with exposed filters to search and create a block for it, 2. create a view with no filters but fields and make a block for it. How can I have the search block display only the results pages but not itself? Commented May 18, 2013 at 22:16

1 Answer 1

0

This is pretty simple to do with a little coding:

First create a "Display output" template inside your theme folder that will only target the relevant view (check options using "Theme: Information" bottom right under "Advanced" when you are on your view administration page). Copy the contents of "views-view.tpl.php" inside the file and clear the caches.

After that modify the original filter output:

<?php if ($exposed): ?>
  <div class="view-filters">
    <?php print $exposed; ?>
  </div>
<?php endif; ?>

to what you need:

<?php if ($exposed): ?>
  <div class="view-filters">
    <?php if (!isset($_GET['something'])): ?>
    <?php print $exposed; ?>
    <?php else: ?>
    <?php print l(t('Back to search'), $_GET['q']); ?>
    <?php endif; ?>
  </div>
<?php endif; ?>

You will just have to replace "something" inside that $_GET to a value that is actually used in your filters (check the URL when you have a search performed - it will look like example.com?something=value1&somethingelse=value2). Since views adds all the filter keys to the URL when a search if performed you can pick any of them.

3
  • Hi there, tried that but not working for me...I pasted this into my view-view.tpl.php <br/> <br/> Commented May 26, 2013 at 4:47
  • <?php if ($exposed): ?> <div class="view-filters"> <?php if (!isset($_GET['may16.localhost:8082/results-page-content-type-results'])): ?> <?php print $exposed; ?> <?php else: ?> <?php print l(t('Back to search'), $_GET['q']); ?> <?php endif; ?> </div> <?php endif; ?> Commented May 26, 2013 at 4:51
  • You'll have to use a single $_GET parameter not the actual URL of the site. In my code example those parameters are something and somethingelse. Other than that you may also want to use view-view--myviewname.tpl.php or similar as the template to just target the relevant view (myviewname should be your actual view name).
    – Madis
    Commented May 26, 2013 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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