Only first record found in Multi Record section

5 posts by 2 authors in: Forums > CMS Builder
Last Post: February 15, 2011   (RSS)

I have a Multi Record section that has an index page listing articles' headlines - http://masselsm.temporaryurl.biz/about-boating.php - which link to individual articles. The index only seems to find the first article - http://masselsm.temporaryurl.biz/about-boatingDetail.php?Is-boating-affordable-1 - with the subsequent articles I get a "Record not found" error message; e.g. http://masselsm.temporaryurl.biz/about-boatingDetail.php?Tips-from-the-toolbox-2.

Any suggestions, please?

Here's the code that loads the records. I've included the full code, which includes other elements that are loaded on this page, just in case there's some sort of conflict here.

======

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/masselsm/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($articlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$articlesRecord = @$articlesRecords[0]; // get first record


// show error message if no matching record is found
if (!$articlesRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}


// load records
list($panel_logosRecords, $panel_logosMetaData) = getRecords(array(
'tableName' => 'panel_logos',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$panel_logosRecord = @$panel_logosRecords[0]; // get first record

// show error message if no matching record is found
if (!$panel_logosRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}

// load records
list($panel_snowmobile_logosRecords, $panel_snowmobile_logosMetaData) = getRecords(array(
'tableName' => 'panel_snowmobile_logos',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$panel_snowmobile_logosRecord = @$panel_snowmobile_logosRecords[0]; // get first record

// show error message if no matching record is found
if (!$panel_snowmobile_logosRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}

?>

======

Thanks!
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [NigelGordijk] Only first record found in Multi Record section

By Jason - February 15, 2011

Hi Nigel,

The issue here probably isn't where you're selecting from the article section, but after it. You have 2 spots below this code where you can issue an "Record Not Found" error.

What's happening is that you're selecting from articles, panel_logos, and panel_snowmobile_logos, all using "whereRecordNumberInUrl(1)" This means it will only work when all three have a record with the same number (in this case 1). It looks like panel_logos and panel_snowmobile_logos are single record sections. If this the case, remove the "where" clauses from those queries. Single record sections will only ever have 1 record, so there is no need to do a search.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [NigelGordijk] Only first record found in Multi Record section

By Jason - February 15, 2011

Hi Nigel,

You do want to use the where clause for your multirecord section, just not the single record sections. Try this:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/masselsm/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($articlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$articlesRecord = @$articlesRecords[0]; // get first record

// load records
list($panel_logosRecords, $panel_logosMetaData) = getRecords(array(
'tableName' => 'panel_logos',
'limit' => '1',
));
$panel_logosRecord = @$panel_logosRecords[0]; // get first record

// load records
list($panel_snowmobile_logosRecords, $panel_snowmobile_logosMetaData) = getRecords(array(
'tableName' => 'panel_snowmobile_logos',
'limit' => '1',
));
$panel_snowmobile_logosRecord = @$panel_snowmobile_logosRecords[0]; // get first record

?>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Only first record found in Multi Record section

Perfect! Many thanks for your help.
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net