Replace Record Number [num] with another field

4 posts by 2 authors in: Forums > CMS Builder
Last Post: December 21, 2012   (RSS)

By sidcam - December 13, 2012

I'm downloading MLS real estate data and have to do a full refresh of the data nightly.

That means the default search/display field Record Number [num] changes daily for each record. This is creating problems for bookmarking records, searching, etc. It's also becoming a very long number as the field grows by 15k+ every day.

How do I change it so one of my own (constant) numbered fields (i.e. the property's MLS number) is used at the end of the URL for finding/searching instead of num? I'll also be using the property's address in the title before it for SEO reasons.

Thanks
Sid

By gregThomas - December 14, 2012

Hi Sid,

Have you got allowSearch set to true in your getRecords function on your details page? I would change the getRecords function so that it doesn't use a where statement and has allowSearch set to true. Then change your URL's to your details page so they find the unique value in your constant field:

detailPageFile.php?your_own_constant_field=32&title_goes_here

You can read more on other options here:

http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html

Thanks!

Greg

Greg Thomas

PHP Programmer - interactivetools.com

By gregThomas - December 21, 2012

Hi Sid, 

I think you can fix the issue with URL's breaking when they have spaces by using the url encode function instead of the htmlencode function:

 <a href="http://www.domain.com/detail-page.php?<?php echo urlencode($record['street_number']) ?>-<?php echo urlencode($record['street_name']) ?>-<?php echo urlencode($record['street_suffix']) ?>-<?php echo urlencode($record['city']) ?>-<?php echo urlencode($record['state']) ?>-<?php echo urlencode($record['zip_code']) ?>&matrix_unique_id=<?php echo urlencode($record['matrix_unique_id']) ?>">LINK</a> 

If you want to completely modify the structure of a URL to make it more human readable I would look into using mod rewrite in your .htaccess file. You would need a mix of these two rules:

http://stackoverflow.com/questions/7578056/url-rewriting-variable-name

http://stackoverflow.com/questions/904075/using-mod-rewrite-to-change-url-with-username-variable

Using this method should make URLs look better without having to heavily modify CMS Builder to use the matrix_unique_id as the num field.

If you would like us estimate the cost of creating human readable URL's for you, send an e-mail to consulting@interactivetools.com.

Thanks

Greg

Greg Thomas

PHP Programmer - interactivetools.com