Linking to a different listingDetail.php pages

3 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: June 5, 2013   (RSS)

By andybarn - May 26, 2013

Hi

I have Sales properties and Rentals properties on the same Website. I have created 2 different search results pages called listings_sales.php and listings_rentals.php (based on the listings.php page) This works great.

Now I want to create 2 different Details pages, one for Sales and one for Rentals.

For Sales I use the default listingDetail.php page and link to it as follows

<a href="<?php echo $listing['_link'] ?>" class="button style1">Click Here</a>

For Rentals I have created a listingDetail_rentals.php page (based on listingDetail.php) but not sure how to link to this from the search results page listings_rentals.php. Please could you let me know how to link to this page?

Thanks

Andy

By gregThomas - May 27, 2013

Hi Andy, 

I would do something like this:

<?php if($listing['sale_or_rental_field'] == 'sales'): ?>
  <a href="<?php echo $listing['_link'] ?>" class="button style1">Click Here</a>
<?php else: ?>
  <a href="listingDetail_rentals.php?<?php echo urlencode($listing['address']).'-'.$listing['num']; ?>" class="button style1">Click Here</a>
<?php endif; ?>

This is just example code, so you might have to make a few changes to get it working. You'll need to change sale_or_rental_field to the field that stores if a property is rental or sales, and the value that would make it a sales type.

So if the record is a sales record, it will display the normal _link, but if it's a rental record type, then it will link to the listingDetail_rentals.php page with the num and first line of the address in the url.

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com