Have menu working in list page but it wont work on detail page
6 posts by 3 authors in: Forums > CMS Builder
Last Post: August 14, 2014 (RSS)
By willydoit - July 30, 2014
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.
By ross - July 31, 2014
Hi willydoit
Thanks for posting. I see what you are aiming for here and my first suggestion is to change this code (on priory_detail.php):
// load records from 'bridlington_priory'
list($bridlington_prioryRecords, $bridlington_prioryMetaData) = getRecords(array(
'tableName' => 'bridlington_priory',
'loadUploads' => true,
'allowSearch' => true,
));
to
// load records from 'bridlington_priory'
list($bridlington_prioryRecords, $bridlington_prioryMetaData) = getRecords(array(
'tableName' => 'bridlington_priory',
'loadUploads' => true,
'allowSearch' => false,
));
If that doesn't get things going, could you post a copy of the whole detail page so I can review all the code?
Thanks!
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/
By willydoit - August 1, 2014
Hi Ross,
Thanks for that, unfortnately it didn't make any difference. I have uploaded the full priory_detail.php for you to look at. I cannot understand why it doesn't work as it works fine on the listing page and I am loading the same records.
By gregThomas - August 5, 2014
Hi willydoit,
I've had a look at your code, and it looks fine to me. For this part of your code:
<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>
What are you storing as the value for the field? Is it the record num? (See attached image for example).
I'm wondering if the code isn't working because the num value isn't being sent over.
Thanks,
Greg
PHP Programmer - interactivetools.com
By willydoit - August 5, 2014
Hi Greg,
I am not in the office at the moment and it was last week when I created the page but working from memory it is the record number.
Hi willydoit,
I'm still not sure what's causing the issues. Would it be possible to send me a link to the page so I can do some testing? If you don't want to post the link in the forum you can send it in an email to support@interactivetools.com.
Thanks!
Greg
PHP Programmer - interactivetools.com