Index not linking to a page

3 posts by 2 authors in: Forums > CMS Builder
Last Post: September 7, 2012   (RSS)

By NigelGordijk - September 6, 2012

I have an index page that links properly to the first item on the list, but then can't find anything else on the list.

http://www.wilmot.ca/departments-public-works-index.php

Also, if I move the item called "Testing" to the top of the list, that's where the link to "Public Works Department" goes.

Any idea why, please?
Nigel Gordijk

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

Re: [NigelGordijk] Index not linking to a page

By Jason - September 7, 2012

Hi Nigel,

I've taken a look at your detail page and have noticed some issues. The first thing is that before you select your public works record, you select 4 other records using the function "whereRecordNumInUrl(1)". It only really makes sense to have this once per page, since record numbers aren't going to be matching between sections. Also, if these sections are single record sections, you don't need a where clause at all, since there will only ever be 1 record in that section.

You're retrieving your public works record like this:

list($index_public_worksRecords, $index_public_worksMetaData) = getRecords(array(
'tableName' => 'index_public_works',
));

list($index_public_worksRecords, $index_public_worksMetaData) = getRecords(array(
'tableName' => 'index_public_works',
'limit' => '1',
));
$index_public_worksRecord = @$index_public_worksRecords[0]; // get first record

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


Since both of these calls use the same variable name, the second call overwrites the first. This is where you would be looking to use the where clause.

Try this:


list($index_public_worksRecords, $index_public_worksMetaData) = getRecords(array(
'tableName' => 'index_public_works',
));

list($index_public_worksRecords, $index_public_worksMetaData) = getRecords(array(
'tableName' => 'index_public_works',
'where' => whereRecordNumberInUrl(0),
'limit' => '1',
));
$index_public_worksRecord = @$index_public_worksRecords[0]; // get first record

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


Hope this helps get you started
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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