Property Types with Subtypes, "We also have ..."

16 posts by 3 authors in: Forums > CMS Builder
Last Post: April 9, 2010   (RSS)

Re: [chris] Property Types with Subtypes, "We also have ..."

By (Deleted User) - April 8, 2010

Logic prevailed - I managed to persuade the client that just the checkboxes to Let or Buy were sufficient.

Thankfully.

I will have a look at the logic for sale price/poa/rental price later today --> it looks great from first glance :).

I have to say, the support we are getting is superb, and I'm learning a heck of a lot from these code examples!

By (Deleted User) - April 8, 2010

Hi,

Okey dokey, because we are down to just the two checkboxes, the code is slightly different. This is what I have. This works for me, so I'm sharing it in case others are interested [:)]

search.php
Are you looking for property
<input type="checkbox" name="to_let" id="to_let" />
to Let or
<input type="checkbox" name="to_buy" id="to_buy" />
to Buy?</p>


list.php

$where = '1'; // start with an "accept all" where condition

// add where condition for property_type
if (@$_REQUEST['property_type']) {
$property_typeCSV = join(',', $_REQUEST['property_type']);
$where .= " AND property_type IN (" . mysql_escape($property_typeCSV) . ")";
}

// build on to cover 'to_buy' and 'to_let' checkboxes
if (@$_REQUEST['to_buy'] == 'on' && @$_REQUEST['to_let'] =='on') {
// do no filtering
} else if (@$_REQUEST['to_buy'] == 'on') {
// show purchase properties
// p_o_a is a checkbox!
$where .= " AND (price <> '' OR p_o_a = '1')";
} else if (@$_REQUEST['to_let'] =='on') {
// show rental properties
$where .= " AND rental_price <> ''";
}

// load records
list($propertiesRecords, $propertiesMetaData) = getRecords(array(
'tableName' => 'properties',
'where' => $where,
));


I also found it incredibly useful to stick
<?php echo $where ?>
at the top of the content area of list.php so I could see the where clause being built up. Never underestimate the power of debug statements!

*cough*p_o_a is a checkbox*cough*

Also - checking that your code actually /works as expected/ before posting helps too. <.< >.> nothing to see here [;)]

By (Deleted User) - April 8, 2010

Right, now I know this one is simple, and I'm being a thicky.

We have a dropdown:

<select name="location">
<option value="1">City Centre</option>
<option value="2">City Suburbs / Business Parks</option>
<option value="3">Other small town</option>
<option value="4">And another small town</option>
<option value="5">Rest of County</option>
</select>


These directly map to the field "locations" which has been set up in the database. Locations is of type 'list'.

You can choose which location you want on the filter screen, and it will show you the properties for that location.

Now, excuse me for a minute here.

*wunch* *wunch* *wunch* *wunch*

Ok, thats better. That was me just banging my head on the desk.

How do I enable an "All Locations" option?

I tried adding

<option >All</option>

but that doesn't work. I seem to need to be able to simulate the Location parameter not being passed at all, as far as I can see, and I'm not sure how to do that.

I also considered using a magic number, e.g., -999, for the value, and trapping it on the list page, but then I realised that the filtering is kinda already done by the time I get to it, and it has already tried to find all locations with the location id -999, and got none.

Then my head imploded.

I have rifled through all the posts I can see, and checked out the latest CMS cookbook, but no joy.

By Jason - April 8, 2010

Hi,

try:

<option value="">All</option>

Let me know if that works.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Property Types with Subtypes, "We also have ..."

By (Deleted User) - April 9, 2010

Guess what.

It does. Works perfectly.

Sheesh.

Thanks!

p.s. Mental Note - setting a list item value as blank in Dreamweaver does not do what you think it does. D'oh.