Only first record found in Multi Record section

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

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: [Jason] Only first record found in Multi Record section

Hi, Jason.

I've removed all of the occurrences of 'where' => whereRecordNumberInUrl(1), and now when you click on any headline link here - http://masselsm.temporaryurl.biz/about-boating.php - it displays the same content, even though the URL shown in the browser indicates it's a different page. e.g. http://masselsm.temporaryurl.biz/about-boatingDetail.php?Is-boating-affordable-1 and http://masselsm.temporaryurl.biz/about-boatingDetail.php?Tips-from-the-toolbox-2.

Any idea why this might be, please?

======

<?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',
'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

?>
Nigel Gordijk

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

about-boatingdetail.php 10K

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