Show sub-sections on new page

4 posts by 2 authors in: Forums > CMS Builder
Last Post: April 26, 2015   (RSS)

By Toledoh - April 23, 2015

I'm sure this is simple, but I can just can't get my head around it.

I've got a category section;

Heading
-sub
-sub
-sub

Heading
-sub
-sub
-sub

On HOME page, I show the heading, and link to SECTION page to show the sub-items from the selected heading

ie: HOME

list($pagesRecords, $selectedPages) = getCategories(array(
'tableName' => 'pages', //
'categoryFormat' => 'onelevel', // showall, onelevel, twolevel, breadcrumb
'defaultCategory' => '', // Enter 'first', a category number, or leave blank '' for none
));

...

<?php foreach ($pagesRecords as $categoryRecord): ?>
  <a href="section.php?num=<?php echo $categoryRecord['num'] ?>"><?php echo $categoryRecord['name'] ?></a>
<?php endforeach; ?>

SECTION

// load records from 'pages'
list($pagesRecords, $selectedPages) = getCategories(array(
'tableName' => 'pages', //
'categoryFormat' => 'onelevel', // showall, onelevel, twolevel, breadcrumb

// advanced options (you can safely ignore these)
'rootCategoryNum' => '?', // Only categories _below_ this one will be shown (defaults to blank or 0 for all)
));

How do I determine the rootCategoryNum of the item I selected on the previous page? 

Cheers,

Tim (toledoh.com.au)

By Toledoh - April 23, 2015

I ended up with the following - but I'm sure it's a bit rough!


$url = $_SERVER['REQUEST_URI'];
$query = parse_url($url, PHP_URL_QUERY);
$vars = array();
parse_str($query, $vars);

list($pagesRecords, $selectedPages) = getCategories(array(
'tableName' => 'pages', //
'categoryFormat' => 'onelevel', // showall, onelevel, twolevel, breadcrumb

// advanced options (you can safely ignore these)
'rootCategoryNum' => $vars['num'], // Only categories _below_ this one will be shown (defaults to blank or 0 for all)
));

Cheers,

Tim (toledoh.com.au)

By Toledoh - April 26, 2015

Hey Ross,

If this is working - and not "bad code" then I'm happy!  Thanks.

Cheers,

Tim (toledoh.com.au)