Category Menu Documentation

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

By kitsguru - May 18, 2014

I have been trying to find the documentation for the Category Menu section Editor and getCategories function call.I can find bits and pieces in the tutorial in the forum and scattered around in other posts but finding what I want has taken me over 4 hours.

Also I found reference to the fact that a code generator for the Caterory Menu item was supposed to be in the next release - dated 2008. Is this every going to be released?

SO what are all the options for getCategories and what do they do?

Plugin development documentation is also hard to come by.

The lack of documentation is very frustrating, PLEASE, PLEASE -- do this and add it to the documentaton pages and not bury it in the forums.

Jeff Shields

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.

Thanks!

Dave Edis - Senior Developer
interactivetools.com

By kitsguru - May 19, 2014

Thanks for this Dave

Jeff Shields

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