Hi all,
Thanks to Ross's help I have a simple menu facility which uses the content of a list field in a table
I have set this up on a list page with this code at the top following my table load element
// redirect on submit priory menu drop down
if (@$_REQUEST['submitPrioryForm']) {
header ("Location: priory_detail.php?member=". $_REQUEST['prioryID']);
}
and this code in the body of the page
<form method="post" action="?">
<input type="hidden" name="submitPrioryForm" value="1">
<h3>Priory Menu</h3>
<select name="prioryID">
<?php foreach (getListOptions('bridlington_priory', 'pages') as $value => $label): ?>
<option value = "<?php echo $value;?>" <?php selectedIf($value, @$_REQUEST['pages']);?>>
<?php echo $label; ?></option>
<?php endforeach ?>
</select>
<br/>
<div align="center">
<input type="submit" name="search" value=" Show Page "/>
</div>
</form>
Using the above I can select an option from the drop down list and click the submit button and I am taken to the priory_detail.php page with the correct info loaded. via a url something like "/listings/priory_detail.php?8"
What I wanted to do was to recreate the same functionality on the detail page priory_detail.php so I replicated the above in the priory_detail.php page and also added the load records code which you would normally find on a list page to my existing load records info in order to combine list and detail page functionality. This is now as below.
// load records from 'bridlington_priory'
list($bridlington_prioryRecords, $bridlington_prioryMetaData) = getRecords(array(
'tableName' => 'bridlington_priory',
'loadUploads' => true,
'allowSearch' => true,
));
// load record from 'bridlington_priory'
list($bridlington_prioryRecords, $bridlington_prioryMetaData) = getRecords(array(
'tableName' => 'bridlington_priory',
'where' => whereRecordNumberInUrl(0),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$bridlington_prioryRecord = @$bridlington_prioryRecords[0]; // get first record
if (!$bridlington_prioryRecord) { dieWith404("Record not found!"); } // show error message if no record found
// redirect on submit priory menu drop down
if (@$_REQUEST['submitPrioryForm']) {
header ("Location: priory_detail.php?". $_REQUEST['prioryID']);
}
?>
However I find that although the drop down list populates, when I hit the submit button I get a record not found error and the url produced looks like "/listings/priory_detail.php?" without the record id number on the end.
Is there something different I need to do to get the code which works fine on the list page to work on a detail page?
Without wishing to complicate things further I would also like to know if it is possible to have a more descriptive url display so that the url also includes the title which displays in the menu box ie priory_detail.php?Priory Records-9 as can be achieved when populating a detail page directly from a list page link.
Thanks in advance for any/all help provided.