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

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

Thanks for the reply.

I did what you suggested and then defined my Viewer URL as this:

"street_number, street_name, street_suffix, city, state, zip_code, matrix_unique_id"

But my list page's <?php echo $record['_link'] ?> only shows the first field (regardless of what it is) then it still shows the system's record number (i.e. detail-page.php?<field1>-<num>). When you click the link it doesn't go to the correct record either, it goes to the first record in the DB.

Mapping that all out manually with "matrix_unique_id" being the field searched on like this:

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

ALMOST works except the URL breaks because there's spaces (instead of dashes) in the URL where there's spaces in a field (in the example below, after "Austin" and "St.").

http://www.domain.com/detail-page.php?4413-Austin Pass-Drive-St. Charles-MO-63304&matrix_unique_id=31177685

Ultimately, what I want to accomplish is a clean domain like this (with my detail page being the index.php in /homes/):

http://www.domain.com/homes/4413-Austin-Pass-Drive/St.-Charles/MO/63304/31177685/

Is there anyway consulting services could make it so this one table is rewriting over "num" with my matrix_unique_id field (or substituting matrix_unique_id for num when defining records)?

I'd really like to eliminate "matrix_unique_id" from the URL since it doesn't mean anything to anybody except it's the only unique number in the database for searching/saving records (since "num" changes daily). Renaming the field to something shorter (like "id") creates a problem for my import scripts which match the schema to the first line in my txt files (which is defined by the source, not me).

Thanks, Sid

 

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