Hi there;

I am working a Drupal 6 project and I am creating a views base search for Stock Image selling system. I have a number of search filters in my search panel and I already done those thing by using views.
My site is exactly IstcokImages stock image selling site and my search panel is look like Istockimage search..

http://www.istockphoto.com/

http://www.istockphoto.com/search/text/apple/source/basic#1fc0e90d

In my view, all the filtering functionalists perfectly working. I have a .tpl file to search result. ( filter result )

views-view-fields--search.tpl.php

this is the my .tpl file and I can call all the variables and I already done this "result" page teaming.

I used <?php print_r($row); ?> to get the available variables and I called them like <?php print $row->term_data_name;?> .

but my problem is teaming the "exposed filter fields" that I exposed in my search view.

In my view in Basic settings I selected Exposed form in block: Yes then I got a block named "Exposed form: search-page_1" and I enable that block for the per-defined my region and it perfectly apples and it renders me the exposed fields.

Then I created a .tpl file for that Exposed block, named "block-views--exp-search-page_1.tpl.php" and that .tpl file is perfectly applying.

my problem is coming now..!!!

How I call the exposed fields in my .tpl file (block-views--exp-search-page_1.tpl.php )

I tried

<?php
print_r (drupal_render($form));
print_r($widget);
print drupal_render_form('views_filters', $form);
print drupal_render($form) ;
?>

none of these work for me.

and I tried

<?php
dprint_r($form);
?>

and It gives me Undefined function error.

Gys I am so so fed-up with this tricky point and please help me to get this done.

Thank you
Cheers

Comments

nevets’s picture

As a start you might want to use Better Exposed Filters, make sure you use the right version (depends on both version of Drupal AND views). I would start with using css to get the vertical instead of horizontal layout. And a side note, I would consider using Drupal 7 for new sites.

umanda’s picture

Hei nevets ,

Thank you for your reply and I am using Better Exposed filters and all my modules are up to date.

thank you and cheers.

any other idea ???

nevets’s picture

What are you still trying to achieve?

umanda’s picture

hei nevets

I what I did I copied all generated markup (exposed form by view ) and put those in custom block. but this is terribly stupid work. but I did that because I need to show a some of result for my client. but I know my decision is very very ugly.
But did that. I need to finish it in very smart way

Thank you mate
Cheers

nevets’s picture

Views can have block displays which you can place in any region on block admin page.

umanda’s picture

Yes of course I can expose my view as a block and I did it. my question is how I theme that block. In my firsr post I explain what I did almost.

As your idea I did that case and I got a block for the my view. and I created a .tpl file for that "block" and it is also applying.

my question is how call the exposed form and form elements with this created block tpl file..???

Thank you again
Cheers

umanda’s picture

If you build a View with an exposed filter you may want to put this filter in a block. This is can be done to separate filter from view results and to display exposed filter in any part of your website.

To do this, go and edit your view.

1. Under Basic settings you will see an option: Exposed form in block (UPD: in new Views interface the path looks like this: Advanced > Exposed Form) Select Yes and save your View.
2. Now you can go to Blocks and see your View’s Exposed Filter appeared in the block’s list. Nice!

But what if you want to theme this block and change the way exposed filter behaves, what do you do?

Since there is no any mention of “exposed filter in a block template file” in Views Theming information list, it is a bit tricky to guess which file to edit and how to name it. Here is what you should do:

Go to Views installation folder (sites/all/modules/views) and look in ‘theme’ folder. There you will find ‘views-exposed-form.tpl.php’ file.
Copy this file to your current theme directory, in my case it is sites/all/themes/timonweb
Now, check your views name, in my case, it is ‘user-comments’.
Rename your newly copied file by following this formula: views-exposed-form--view-name.tpl.php (NOTE “--”). In my case file’s name is: views-exposed-form--user-comments.tpl.php
Clear your theme cache by flushing it with admin_menu module, or by going to your View and clicking “Rescan Template Files” under Style settings -> Theme Information.

That’s it, now you can edit views-exposed-form--user-comments.tpl.php file and all changes will be shown in a block with your exposed filter.

Original post is from

http://timonweb.com/how-display-views-exposed-filter-block-and-theme-it

Cheers