not selecting the right record

4 posts by 2 authors in: Forums > CMS Builder
Last Post: November 2, 2009   (RSS)

my multi-record section is not pulling the right source record (for some parts but others it works fine.

this is the source page:
http://www.tpschool.org/stu/overview.php

It loads the multi-record sub-sections onto the page. When you load one of the subsections a subnav menu of all the other options also loads on the page.

The "title" of the record is pulled to use in the page title. However, when you change to one of the other subsections the data on the page changes correctly but the page title does not change.

Here is the code on the list page:

<?php

require_once "/usr/www/users/thephila/cmsAdmin/lib/viewer_functions.php";

list($stu_resourcesRecords, $stu_resourcesMetaData) = getRecords(array(
'tableName' => 'stu_resources',
'where' => whereRecordNumberInUrl(1),
'loadUploads' => '0',
'orderBy' => 'box ASC',
));
$stu_resourcesRecord = @$stu_resourcesRecords[0]; // get first record

// show error message if no matching record is found
if (!$stu_resourcesRecord) {
print "Record not found!";
exit;
}
list($stu_overviewRecords, $stu_overviewMetaData) = getRecords(array(
'tableName' => 'stu_overview',
'where' => whereRecordNumberInUrl(1),
'loadUploads' => '0',
'limit' => '1',
));
$stu_overviewRecord = @$stu_overviewRecords[0]; // get first record

// show error message if no matching record is found
if (!$stu_overviewRecord) {
print "Record not found!";
exit;
}

?>


here is the code for the viewer page - I am pretty sure the problem occurs because of the get first record code but I am drawing a blank on how to get around it.

<?php

require_once "/usr/www/users/thephila/cmsAdmin/lib/viewer_functions.php";

list($stu_resourcesRecords, $stu_resourcesMetaData) = getRecords(array(
'tableName' => 'stu_resources',
'limit' => '1',
));

$stu_resourcesRecord = @$stu_resourcesRecords[0]; // get first record


// show error message if no matching record is found
if (!$stu_resourcesRecord) {
print "Record not found!";
exit;
}

?>

Any help is appreciated - thanks.

Re: [craighodges] not selecting the right record

By Dave - October 29, 2009

Hi Craig,

Can you attach both files to this thread? If I can see how the code is outputting the title value that will help me figure out what the issue is.

Thanks!
Dave Edis - Senior Developer
interactivetools.com

Re: [craighodges] not selecting the right record

By Dave - November 2, 2009

Hi Craig,

This was a little tricky, but I think I figured it out. It's because on viewres_stu.php these lines are commented out:

list($stu_resourcesRecords, $stu_resourcesMetaData) = getRecords(array(
'tableName' => 'stu_resources',

'limit' => '1',
));


The where line would get the number from the url, so that code is always just loading the first record.

So this line shows the title from the first record:
<title><?php echo $stu_resourcesRecord['title'] ?>

And then lower this line shows the same value but it's different then:
<h1 class="pg_hdr"><?php echo $stu_resourcesRecord['title'] ?></h1>

Which means one of these includes must have some viewer code that is overwriting $stu_resourcesRecord['title'] or $stu_resourcesRecord

<?php include("../headercode.php");?>
<?php include("../home_link.php"); ?>
<?php include("../nav_top.php");?>
<?php include("substu.php");?>
<?php include("../content_subnavtop.php");?>

What you can try is print <?php echo $stu_resourcesRecord['title'] ?> after each to quickly figure out what file it's being changed in.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com