Do not show first record

5 posts by 2 authors in: Forums > CMS Builder
Last Post: October 1, 2012   (RSS)

By Toledoh - September 29, 2012

Hi Guys,

There's probably a very simple way to action this...

I've got a combo page, with a side navigation (list) of stores, and a main div of the store details. The file is stores.php.

If I load this page, because there is no ?title-31 , it shows the first record.

Is it possible to say "if no record selected, show ..."

Thanks!
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] Do not show first record

By gregThomas - October 1, 2012

Hi,

I think the easiest way to solve this problem is to use a where statement in your getRecords function and get the page num value from the URL manually. Then if there is no number in the URL you can set getRecord to pull whatever record you want as the default. I would do something like this:

//This function gets the last number from the URL. If there is no number it will return 0;
$number = getLastNumberInUrl();
//This if statement will set the $number variable to the number 3 if it is currently less than 1. Change the number 3 to whatever record you want to load.
$number = ($number < 1)? '3' : $number;

//This getRecords function uses a where statement to pull correct record from a table. Make sure allowSearch is set to false or you could run into problems.
list($mainContents, $test_1MetaData) = getRecords(array(
'tableName' => 'test_1',
'where' => "`num` = '$number'",
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$mainContent = @$mainContents[0]; // get first record


Thanks
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Do not show first record

By Toledoh - October 1, 2012

Thanks Greg!

Rather than showing one of the items from that table, could you show something else... such as "Welcome to the directory, please make a selection from the left"... ?
Cheers,

Tim (toledoh.com.au)

Re: [greg] Do not show first record

By Toledoh - October 1, 2012

Brilliant!
Cheers,

Tim (toledoh.com.au)