Jump to content

Advanced search form


Pitbull
 Share

Recommended Posts

Hi forum i need to make a search form to search filter property fields like the Skyscrapers profile i download and try to find out how to do it

but i am confused.. the pages layout is like this

Property Sales
  • Houses | Maisonettes | Apartments | Villas

              --Apartments

              -- Villas

                        -----Luxury Stone Villa 455tm

  • Plots
  • Commercial Properties

i need a search engine to search this fields

  • City
  • Town
  • Property Type
  • Property Title

it will be perfect if somebody that have made a search form with filters and can find time to post a step by step guide how to do.. (i am so newbie)

thank you in advance and sory for my bad english

Link to comment
Share on other sites

Hi Pitbull,

I am currently working on a search form that has drop downs of categories, input fields and allows you to search a range of values, in my case it is ages. I will be sure to share my code when/if I ever get it completely figured out and working. I am new to pw and have a basic understanding of php, so I am taking Ryan's example from the skyscraper profile and altering it to my needs. 

Hopefully I can get it complete soon and share as many others do in these forums.

Link to comment
Share on other sites

Hi Pitbull,

I hope this first part will help you get started. I have not figured out the output of the form yet, but hopefully I will soon or some other generous soul will have time.

Since pw has now become my go to tool because its cool like that :), I decided to build a mock site so I could use it as a reference library.  I want to learn as much as I can about it, so I was interested in this concept here and I am using this structure. After building every thing successfully to much satisfaction and ease with pw I thought it would be awesome to add some search functionality. Please note that I have never built a search form to this degree, so it could be completely wrong. Also, this is just the form part and I am still working to get it to output (which im struggling to achieve). This is all based off Ryan's skyscraper example.

So with that said, I thought each employee would have the fields of first name, last name, job title, department, year and to complicate things a bonus pay which is in currency format :).

Here is how I output all of that. *note, I removed the markup to cut down on the size of code for demonstration purposes.

$employees = $pages->find("template=employee, limit=10");
         foreach ($employees as $employee) { 
          //This outputs the "location" the employee is from. This is also a drop down in the search form.
          echo $employee->rootParent->title;
          // Text field in search form, so is last name, job title and bonus pay
          echo $employee->first_name;
          echo $employee->last_name;
          echo $employee->job_title;
          //This outputs the "department" which is a page field and is a drop down in the search form.
          echo $employee->department->title;
         echo number_format($employee->bonus_pay, 2);
         }

Now to the search form. All is pretty self explanatory except for the  bonus pay part. I wanted to challenged myself (which has now seemed to result in defeat) but, I thought It would be nice to add the ability to search a range of values for the bonus pay field. Again, this is a mock site to learn from and this form may be completely wrong, but it does work for me so far. I am simply attaching it as a reference and for anyone to critique. I am half way through the output (search.php) and will add it when I get it working. Maybe someone else smarter then me can help out, but here are a few examples.

// This builds the selector string as noted by Ryan in his example
$selector = '';

// this gets the first name field..... all other text fields should be similiar
if($input->get->first_name) {
$value = $sanitizer->selectorValue($input->get->first_name);
$selector .= "first_name%=$value, ";
$input->whitelist('first_name', $value);
}

Update!

The form needs a little bit more work, but I will repost it and document it when I clean it up. 

Edited by RJay
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...