Using List and Details Together
4 posts by 2 authors in: Forums > CMS Builder
Last Post: January 25, 2013 (RSS)
By Mohaukla - January 23, 2013
I am using the list part of a Section as part of the menu and using it on the Details page. What is happening is that when you come from a page to the About page the breadcrumb Title is showing up as the first record in the list instead of the second or third record ...
Headlist($about_us_pagesRecords, $about_us_pagesMetaData) = getRecords(array(
'tableName' => 'about_us_pages',
'loadUploads' => true,
'allowSearch' => false,
));
list($about_us_pagesRecords, $about_us_pagesMetaData) = getRecords(array(
'tableName' => 'about_us_pages',
'where' => '', // load first record
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$about_us_pagesRecord = @$about_us_pagesRecords[0]; // get first record
if (!$about_us_pagesRecord) { dieWith404("Record not found!"); } // show error message if no record found
Menu Code
<ul><?php foreach ($about_us_pagesRecords as $record): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo htmlencode($record['title']) ?></a></li>
<?php endforeach ?>
<li><a href="#">Staff</a></li>
</ul>
Breadcrumb Code
<ul class="breadcrumb pull-right">
<li>You are here <span class="divider">:</span> </li>
<li> About Rileys <span class="divider">:</span> </li>
<li> <?php echo htmlencode($about_us_pagesRecord['title']) ?> </li>
</ul>
So the content for the first record shows instead of the one clicked
Example Links:
Record 1: http://rileytours.com.r15.millsys.org/about.php?About-Us-1
Record 2: http://rileytours.com.r15.millsys.org/about.php?General-Information-2
Thanks in advance,
Michael
Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.
"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"
Hi Micheal
I think the reason the page is always returning the first record that you have allowSearch set to false on your second $about_us_pagesRecords getRecords function, changing it to true shoud fix the issue.
I think you might need to change the name of the $about_us_pagesRecords in your first getRecords function, as it will be overwritten by the second getRecords function. You could try something like this:
list($aboutUsMenu, $about_us_pagesMetaData) = getRecords(array(
'tableName' => 'about_us_pages',
'loadUploads' => true,
'allowSearch' => false,
));
list($about_us_pagesRecords, $about_us_pagesMetaData) = getRecords(array(
'tableName' => 'about_us_pages',
'where' => '', // load first record
'loadUploads' => true,
'allowSearch' => true,
'limit' => '1',
));
$about_us_pagesRecord = @$about_us_pagesRecords[0]; // get first record
if (!$about_us_pagesRecord) { dieWith404("Record not found!"); } // show error message if no record found
And then change the foreach loop so that it uses the first getRecords function:
<ul><?php foreach ($aboutUsMenu as $record): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo htmlencode($record['title']) ?></a></li>
<?php endforeach ?>
<li><a href="#">Staff</a></li>
</ul>
Thanks!
Greg
PHP Programmer - interactivetools.com
By Mohaukla - January 24, 2013
list($about_us_Menu, $about_us_pagesMetaData) = getRecords(array(
'tableName' => 'about_us_pages',
'loadUploads' => true,
'allowSearch' => false,
));
list($about_us_pagesRecords, $about_us_pagesMetaData) = getRecords(array(
'tableName' => 'about_us_pages',
'where' => '', // load first record
'loadUploads' => true,
'allowSearch' => true,
'limit' => '1',
));
$about_us_pagesRecord = @$about_us_pagesRecords[0]; // get first record
if (!$about_us_pagesRecord) { dieWith404("Record not found!"); } // show error message if no record found
<ul><?php foreach ($about_us_Menu as $record): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo htmlencode($record['title']) ?></a></li>
<?php endforeach ?>
<li><a href="#">Staff</a></li>
</ul>
I changed the name for the menu reference and the loop and that works fine but changing the allow search did not seem to work.
Any suggestions?
Michael
Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.
"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"
Hi Michael,
Sorry about that, you'll need to change the where statement on the $about_us_pageRecords getRecords function:
list($about_us_Menu, $about_us_pagesMetaData) = getRecords(array(
'tableName' => 'about_us_pages',
'loadUploads' => true,
'allowSearch' => false,
));
list($about_us_pagesRecords, $about_us_pagesMetaData) = getRecords(array(
'tableName' => 'about_us_pages',
'where' => whereRecordNumberInUrl(1),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$about_us_pagesRecord = @$about_us_pagesRecords[0]; // get first record
if (!$about_us_pagesRecord) { dieWith404("Record not found!"); } // show error message if no record found
<ul><?php foreach ($about_us_Menu as $record): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo htmlencode($record['title']) ?></a></li>
<?php endforeach ?>
<li><a href="#">Staff</a></li>
</ul>
This will look for a number at the end of URL and load the record with the same num value from the about_us_pages section. If there is no number in the URL it will load record number one instead.
Let me know if you have any questions.
Thanks!
Greg
PHP Programmer - interactivetools.com