 | |  |
 |

jconnect
Novice
May 30, 2008, 12:47 PM
Post #1 of 5
(149 views)
Shortcut
|
|
List and page viewer in a single page
|
Can't Post
|
|
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 /* STEP 1: LOAD RECORDS - Copy this PHP code block to the TOP of your page BEFORE anything else. */ require_once "/home/content/c/p/a/cpagee/html/cmsAdmin/lib/viewer_functions.php"; /* To generate the list of products */ list($product_listRecords, $product_listDetails) = getRecords(array( 'tableName' => 'product_list', 'where' => whereRecordNumberInUrl(1), 'limit' => '1', )); $product_listRecord = $product_listRecords[0]; // get first record /* To generate the Sidebar to the right */ 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!
|
|
|  |
 |

Dave
Staff
/ Moderator

May 30, 2008, 1:09 PM
Post #2 of 5
(148 views)
Shortcut
|
|
Re: [jconnect] List and page viewer in a single page
[In reply to]
|
Can't Post
|
|
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
|
|
|  |
 |

jconnect
Novice
May 30, 2008, 1:34 PM
Post #3 of 5
(146 views)
Shortcut
|
|
Re: [Dave] List and page viewer in a single page
[In reply to]
|
Can't Post
|
|
Hi Dave, That did it exactly! I am assuming that if no 'where' parameter is specified, it just defaults to the first record? Thanks a million, especially for the super fast response!
|
|
|  |
 |

Dave
Staff
/ Moderator

May 30, 2008, 2:13 PM
Post #4 of 5
(144 views)
Shortcut
|
|
Re: [jconnect] List and page viewer in a single page
[In reply to]
|
Can't Post
|
|
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
|
|
|  |
 |

jconnect
Novice
May 30, 2008, 2:36 PM
Post #5 of 5
(143 views)
Shortcut
|
|
Re: [Dave] List and page viewer in a single page
[In reply to]
|
Can't Post
|
|
Thank you for the clarification. I look forward to really getting into this product! J
|
|
|  |
|