Hi Jac,
Sorry, I thought you wanted to create a completetly seperate page. If you want to display all of the parent categorys if no sub category is selected on the same page, I would do something like this:
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/quanmax/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
// Get the last number from the URL, if there isn't one there set the number as zero.
$mainCat = intval(getLastNumberInUrl());
// load detail record from 'category'
list($categoryRecords, $categoryMetaData) = getRecords(array(
'tableName' => 'category',
'where' => whereRecordNumberInUrl(1), // If no record # is specified then latest record is shown
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$detailRecord = @$categoryRecords[0]; // get first record
if (!$detailRecord) { dieWith404("Record not found!"); } // show error message if no record found
// load list records from 'category'
list($leftMenu, $categoryMetaData) = getCategories(array(
'tableName' => 'category',
'loadUploads' => true,
'categoryFormat' => 'twolevel'
));
//Show either level one or two category pages depending on if a there is a number in the URL
list($rightMenu, $categoryMetaData) = getCategories(array(
'tableName' => 'category',
'loadUploads' => true,
'rootCategoryNum' => $mainCat,
'categoryFormat' => 'onelevel'
));
So if there isn't a number in the URL, the rootCategoryNum will default to 0, and the page will only display top level items. You should be able to keep the same body code as you used last time.
Thanks!
Greg
Greg Thomas
PHP Programmer - interactivetools.com