Using List and Details Together

4 posts by 2 authors in: Forums > CMS Builder
Last Post: January 25, 2013   (RSS)

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

Greg Thomas







PHP Programmer - interactivetools.com

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

Michael Moyers



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

Greg Thomas







PHP Programmer - interactivetools.com