Replace Record Number [num] with another field

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

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:


You can read more on other options here:



Greg Thomas

PHP Programmer -

By sidcam - December 20, 2012

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="<?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."). 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/):

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


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="<?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:

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



Greg Thomas

PHP Programmer -