Help needed with Permalink detail pages please

By willydoit - August 7, 2014

I have managed to set up permalinks for the most part however I am unsure of what is needed when it comes to redirecting old viewer pages. The instructions say 

First find the code that loads the record being displayed. Then determine
which variable is being used to store the record (often $record, $product, or
something similar).

Directly below the code that loads the record, add this code and enter the
record variable between the "()" brackets:
<?php permalinks_301redirectToPermalink($record); ?>

While this may be self explanatory to php and sql programmers it doesn't mean much to me and am hoping someone can explain it better for me using my code as an example.

One of my pages has the following code, where would I insert the <?php permalinks_301redirectToPermalink($record); ?> and what value would I use in the ($record) element?

I dont know if the ($record) element needs to refer to the field that permalinks would use from each of the records in this table but if so that field is establishment_name 

If someone could help me out on this it would be appreciated as I need to have this site completed tomorrow and have no chance unless I can get this sorted. Unfortunately due to a number of issues I wont bore you with I am unable to just play around and test this so will only know if it works when the site goes live which isnt a comfortable place for me.

Thanks in advance

// load record from 'self_catering'
list($self_cateringRecords, $self_cateringMetaData) = getRecords(array(
'tableName' => 'self_catering',
'where' => whereRecordNumberInUrl(0),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$self_cateringRecord = @$self_cateringRecords[0]; // get first record
if (!$self_cateringRecord) { dieWith404("Record not found!"); } // show error message if no record found

?>

Thanks Greg,

thats all perectly clear now.