Category Menu Documentation

5 posts by 2 authors in: Forums > CMS Builder
Last Post: May 24, 2014   (RSS)

By Dave - May 19, 2014

Hi Jeff, 

It's not yet officially supported and has been taken off the development roadmap for now, so that's why there's no docs on it.

The way we develop is that we try things out internally and see what "works" and is popular before making it more generally available.  getCategories() hasn't yet graduated to public supported status (and may not).  We won't drop support for it, but it may be replaced with something better before it makes it public, and that might make some time.  That said, you're free to use it and ask us and we'll likely help if we can.  I've attached the files I use as a reference myself when building category menus, they are: 

  • categorylist.php - a sample viewer for categories with some comments in the code
  • category.ini - /data/schema/ file with default schema structure
  • category.defaultSqlData.php (rename if needed to match this format) - /data/schema/ file with default data

If you upload category.ini and category.defaultSqlData.php to /data/schema/ then go to "Section Editors" they should get automatically created.  Then if you save categoryList.php it should output the content that was just imported.

Another trick if you want to use our undocumented functions is to search for them under /lib/ (eg: search for "function getCategories").  We usually have some docs above the function in the code.  Here's getCategories from /lib/viewer_functions.php

  list($categoryRecords, $selectedCategory) = getCategories(array(
    'tableName'             => 'category',          // REQUIRED
    'rootCategoryNum'       => '0',                 // Only categories _below_ this one will be shown (defaults to 0 for all)
    'defaultCategory'       => 'first',             // Enter 'first', a category number, or leave blank '' for none
    'ulAttributes'          => " class='muList' ",  // add html attributes to <ul> tags
    'selectedCategoryNum'   => '',                  // defaults to getLastNumberInUrl()
    'categoryFormat'        => 'showall',           // showall, onelevel, twolevel, breadcrumb
    'loadCreatedBy'         => false,               // optional, defaults to false, adds createdBy. fields for created user
    'ignoreHidden'          => false,               // don't hide records with hidden flag set

    'ulAttributesCallback'  => 'myUlAttr',          // ADVANCED: custom function to return ul attributes, eg: myUlAttr($category);
    'liAttributesCallback'  => 'myLiAttr',          // ADVANCED: custom function to return li attributes, eg: myLiAttr($category);

    //'debugSql'            => true,
function getCategories($options) {

Again, it's not officially supported, so don't count on it to be, but do feel free to ask questions and we'll help if we can.


Dave Edis - Senior Developer

By kitsguru - May 19, 2014

Thanks for this Dave

Jeff Shields

By Dave - May 22, 2014

Hi All, 

We've been talking about this internally (and I've received some additional feedback over email from other users) and we've decided we're going to work on creating at least a basic code generator for categories in the next week.   I'll post more details here with beta instructions when we have something to test.

And Jeff, if you're still working on this and there's specific things you still can't do let me know. 


Dave Edis - Senior Developer

By kitsguru - May 24, 2014

select list option would be a nice addition to li with optgroup around sub categories. I build me own functions for it and works well.

Jeff Shields