List and page viewer in a single page

5 posts by 2 authors in: Forums > CMS Builder
Last Post: May 30, 2008   (RSS)

By jconnect - May 30, 2008

Hi there,

Let me explain the layout of my site:

I have a products page which outlines two main products. The outline text is managed through the CMS via a page viewer and a list viewer generates the links for the products. When you click on either product, it takes you to a product_details page viewer which loads the appropriate record.

On all my pages I also have a page viewer to the right side which just has some sidebar text.

Everything works great except that when I click on the second product in the products page (and the URL has record # 2 in it), I get an error at the top as follows:

"Notice: Undefined offset: 0 in /home/content/.../product_details.php on line 22"

Also, the side bar text will then not be visible.

The code at the top of the page is:

"<?php

require_once "/home/content/c/p/a/cpagee/html/cmsAdmin/lib/viewer_functions.php";



list($product_listRecords, $product_listDetails) = getRecords(array(
'tableName' => 'product_list',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$product_listRecord = $product_listRecords[0]; // get first record




list($sidebarRecords, $sidebarDetails) = getRecords(array(
'tableName' => 'sidebar',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));

$sidebarRecord = $sidebarRecords[0]; // get first record
?>"



It looks to me like the viewer is trying to see record 2, which of course won't exist for a single page viewer. I tried putting this line " $options['recordNum'] = @$listRows[0]['sidebarDetails'];" before the sidebar line to get the first record but no luck. Any help would be appreciated!

Re: [jconnect] List and page viewer in a single page

By Dave - May 30, 2008

Hi jconnect,

So the sidebar section is a single page/record menu right?

Try removing this line "'where' => whereRecordNumberInUrl(1), " from the sidebar code and add the @ to hide errors so you end up with this:

list($sidebarRecords, $sidebarDetails) = getRecords(array(
'tableName' => 'sidebar',
'limit' => '1',
));

$sidebarRecord = @$sidebarRecords[0]; // get first record


Let me know if that fixes it. If not we'll keep trying.
Dave Edis - Senior Developer
interactivetools.com

Re: [jconnect] List and page viewer in a single page

By Dave - May 30, 2008

That's right, if there is no "where" then it lists all records, and the limit = 1 makes it only return 1.

There's only one record in that section anyway but if there was more you can use limit to control how many are returned.

Glad to be of help! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] List and page viewer in a single page

By jconnect - May 30, 2008

Thank you for the clarification. I look forward to really getting into this product!

J