Navigation menu widget

Category navigation builder widget for use in TPL files

Builds category structure menus in Cotonti templates

#1. List menu

Use this widget to build a flat list:

function navi_list($tpl = 'navi.list', $parent = '', $current = '', $count = 1, $sort = 'path', $blacklist = '', $whitelist = '')

#1.1. Parameters

  • $tpl (string) - TPL file name without extension, e.g. 'navi.list' => 'navi.list.tpl'
  • $parent (string) - Parent category code for the list. Empty to start at structure root. Accepts special keywords:
    • __parent__ => parent category of $current,
    • __root__ => select root-level categories
  • $current (string) - Category code that is marked in the list as current, optional
  • $count (integer) - Count items. 1 = yes (default), 0 = no (optimized speed)
  • $sort (string) - Sort by: path (default) or title (optional)
  • $blacklist (string) - Category codes black list, separated by ; (optional)
  • $whitelist (string) - Category codes white list, separated by ; (optional)

#1.2. TPL usage example

{PAGE_CAT|navi_list('my_menu', '__parent__', $this, 1)}

#1.3. Template customization

Copy the navi/tpl/navi.list.tpl to your theme and customize it to fit your site. Pass customized template name (without extension) as the first argument of the widget function.

#2. Tree menu

Use navi_tree function to generate a nested menu containing categories, subcategories, etc.

function navi_tree($tpl = 'navi.tree', $root = '', $current = '', $depth = 1, $full = 0, $show_root = 0, $siblings = 0, $count = 1, $blacklist = '', $whitelist = '')

#2.1. Parameters

  • $tpl (string) - TPL file name without extension, e.g. 'navi.tree' => 'navi.tree.tpl'
  • $root (string) - Root category code for the tree. Empty to start at structure root. Accepts special keywords:
    • __parent__ => parent category of $current,
    • __root__ => select root-level categories
  • $current (string) - Category code that is marked in the list as current, optional
  • $depth (integer) - Max. depth from root, 0 = unlimited. Default is 1.
  • $full (integer) - Show full tree. 1 = open all tree nodes, 0 = show only current branch (default)
  • $show_root (integer) - Show root element, 1 = yes, 0 = no (default)
  • $siblings (integer) - Show root's siblings, 1 = yes, 0 = no (default)
  • $count (integer) - Count items. 1 = yes (default), 0 = no (optimized speed)
  • $sort (string) - Sort by: path (default) or title (optional)
  • $blacklist (string) - Category codes black list, separated by ; (optional)
  • $whitelist (string) - Category codes white list, separated by ; (optional)

#2.2. TPL usage example

{PAGE_CAT|navi_list('tree_menu', '__root__', $this, 3, 1, 1, 1)}

#2.3. Template customization

Copy the navi/tpl/navi.tree.tpl to your theme and customize it to fit your site. Pass customized template name (without extension) as the first argument of the widget function.

Note that default template only supports up to 3 levels of nesting. You can add more levels but you should code it in the TPL file similarly to the existing levels.

#3. Tabular menu

You can create 2-dimensional table of site categories with this function:

function navi_table($tpl = 'navi.table', $parent = '', $current = '', $count = 1, $sort = 'path', $blacklist = '', $whitelist = '')

#3.1. Parameters

  • $tpl (string) - TPL file name without extension, e.g. 'navi.table' => 'navi.table.tpl'
  • $parent (string) - Parent category code for the list. Empty to start at structure root. Accepts special keywords:
    • __parent__ => parent category of $current,
    • __root__ => select root-level categories
  • $current (string) - Category code that is marked in the list as current, optional
  • $count (integer) - Count items. 1 = yes (default), 0 = no (optimized speed)
  • $sort (string) - Sort by: path (default) or title (optional)
  • $blacklist (string) - Category codes black list, separated by ; (optional)
  • $whitelist (string) - Category codes white list, separated by ; (optional)

#3.2. TPL usage example

{PAGE_CAT|navi_table('my_menu', '__parent__', $this, 1)}

#3.3. Template customization

Copy the navi/tpl/navi.table.tpl to your theme and customize it to fit your site. Pass customized template name (without extension) as the first argument of the widget function.


1. Roffun  20.01.2015 14:27

Полезный плагин, принцип вывода содержимого как у pagelist. 

Не помешала бы возможность содержимое структуры форума также вызывать.

 

2. Kort  30.01.2015 15:04

По форумам несложно сделать похожее. Думаю, в ближайшее время выложу.

3. Виктор  10.06.2016 13:33

Как скрыть категорию System?

4. Виктор  11.06.2016 09:36

а понял невнимательно прочитал, в школе век назад учил немецкий)) $blacklist

5. Roffun  29.08.2016 14:29

Было бы неплохо прикрутить настройку "считать только опубликованные". Плагин считает страницы со всеми статусами, например в черновиках одной категории есть 100 страниц, и опубликованных 12, плагин покажет 112, а нужно 12.

6. Anonymous  08.04.2017 10:44

Огромное спасибо, очень удобный инструмент!

В пункте 2.2. ошибка с navi_list

7. kriptograff  01.10.2017 06:25

неразобрался как подключить категории, например в шаблоне page.list.tpl

какими тегами выводится структа?

Додавання комментарів доступно лише зареєстрованим користувачам