Show 1 record in detail, rest in a list

4 posts by 3 authors in: Forums > CMS Builder
Last Post: April 30, 2009   (RSS)

By sidcam - March 7, 2009

Question. Is there a way to display the latest record in a table on one part of the page (in detail form) and then display the rest of the records in a list starting with the second newest record? Basically I would like to do what newspapers do and have the latest article in a category show up at the top of the page with photos, a summary, larger text, etc. and then have a list of older articles below it with just the title and a link.

I guessing this will require two calls to the same table (one for the details, one for this list) and I'm reading that can be done, but I don't know how to make the list exclude the first record.

Thanks, Sid

Re: [sidcam] Show 1 record in detail, rest in a list

By Dave - March 9, 2009

Hi Sid,

There's a few ways to do that. The simplest is probably to use two viewers. For the first one, add this code to limit the results to just one record:
'limit' => 1,

To the next viewer, add this to start at the second record:
'offset' => 1,

Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Show 1 record in detail, rest in a list

By sidcam - April 28, 2009

Dave-

I need to display content from two Tables on one page. However the record displayed from Table B is dependent on a drop down field selection of the record used from Table A. Is it possible to do relational stuff like that? (Basically the content of Table A is controlled by the user and the content of Table B is controlled by the Admin).

EXAMPLE: CALL A RECORD IN TABLE A

list($TableA-news-storiesRecords, $TableA-news-storiesMetaData) = getRecords(array(
'tableName' => 'TableA-news-stories',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$TableA-news-storiesRecord = @$TableA-news-storiesRecords[0]; // get first record

THEN A RECORD IN TABLE B IS CALLED THAT'S DEPENDENT ON THE OUTPUT OF TABLE A

list($TableB-adsRecords, $TableB-adsMetaData) = getRecords(array(
'tableName' => 'TableB-ads',
'where' => 'Title = "CONTENT OF A FIELD IN TABLE A"',
'limit' => '1',
));
$TableB-adsRecord = @$TableB-adsRecords[0]; // get first record