A code snippet for the Website Baker CMS software. It provides a complete replacement for the builtin menu functions. All menu data is retrieved using a single database query, all types of menu styles (lists, breadcrums, sitemaps) can be generated with extensive customisation of the resulting HTML.

Features

  • Speed

    It is faster than the existing function as it hits the database exactly once per page load. The builtin function hits the database multiple times per function call. This is at the expense of more memory as all page information is stored locally. Realistically, the memory load is not large.

  • Flexibility

    It can generate menus in many different ways. Covering all of the existing menu's abilities (as far as I know) and adding a few more of it's own.

  • Valid XHTML

    The HTML generated by this function is valid XHTML.

  • Easy CSS Styling

    It generates a menu with lots of classes on each element to allow easy styling of the menu via CSS. This should allow the generated menus to be used in pretty much any way, e.g. popups, dropdowns, etc. See websites about CSS menus.

  • Lists, Tables, Spans, or more

    Like the existing function, you can use whatever HTML tag you want to delimit the menu and menu items. UL, OL, DIV, SPAN, TR, etc. Use your imagination.

  • Menu or Breadcrumbs

    All types of menus can be generated as well as breadcrumbs.

  • Custom Formatting

    You may supply your own formatting object to format the menu any way you need to.

  • Backward Compatibility

    An implementation of the existing show_menu and page_menu functions is included that uses show_menu2 to display the menus. This gains the in memory advantages of using show_menu2 with (partial) backward compatibility to the older functions. Note that it is highly recommended to update your templates to call show_menu2 directly.

Download

Source Repository

The homepage of the project is here, however the source repository is stored at google code. See http://code.google.com/p/showmenu2/.

Demo

A demo website showing many of the different types of menus that can be created using this function is at http://code.jellycan.com/sm2test/.

Documentation

Full documentation for the function can be read in the README file (as included in the zip file). Note that this is documentation from the latest version of show_menu2.

Forums

Release announcements for this component are posted to this topic in the Website Baker forums.

Licence

This module is released under the GPL licence.

History

4.6 (22 Apr 2008)
Fix for page_id = 0 in search results. Requires changes to templates, WB settings and possible WB core files. See this post in WB forums.

4.5 (10 Apr 2008)
Support for WB 2.7 multiple groups and publish date (thanks to Thorn for updates). This version still works in WB 2.6.7 and is not substantially different from 4.41 released by Thorn.

4.4 (6 Sep 2007)
Added SM2_ESCAPE flag for HTML escaping of output. Deprecated SM2_NOESCAPE flag and made it the default.

4.3 (29 Aug 2007)
Added SM2_BUFFER flag for output buffering. Added SM2_CURRTREE to restrict output to only the current menu tree.

4.2 (18 Aug 2007)
Added handling for multiple tests with boolean AND/OR logic to conditional formatting. See this sample for an example of usage. Permit whitespace anywhere within conditional expressions.

4.1 (15 Aug 2007)
Added optional else clause to conditional formatting. See this sample for an example of usage.

4.0 (19 Dec 2006)
Add greater than equal (>=), less than equal (<=) logic to conditional formatting. Added ability to test against page level and page ID in the conditional formatting. Removed the sm2_ prefix from the legacy functions in legacy.php so that when including this file the standard show_menu and page_menu functions are transparently redefined to use show_menu2.

3.9 (1 Nov 2006)
Add Not Equal (!=) logic to conditional formatting (thanks to Ezra Peisach for the fix).

3.8 (27 Aug 2006)
Log an error if none of the group 1 flags are specified. Fix bug where private pages that were not accessible by the current user were still visible in the menu (thanks to afbelow for the fix).

3.7 (24 Aug 2006)
Call htmlspecialchars on all strings to ensure that the output menu items are valid HTML. Added new flag SM2_NOESCAPE to turn off this escaping.

3.6 (15 Aug 2006)
Added new flag SM2_SIBLING to show breadcrumbs + current page siblings only.

3.5 (2 Aug 2006)
Added new flag SM2_PRETTY to provide indenting menu HTML for debugging. Added conditional formatting directive (see CONDITIONAL FORMATTING in the documentation).

3.1 (1 June 2006)
Fix bug where menu displays incorrectly on the search results page (Thanks to succhi for updates). Added new flag SM2_NOCACHE.

3.0 (28 May 2006)
Beta 8 released as version 3.0 unchanged

3.0 beta 8 (22 May 2006)
Last major rewrite for 3.0 release. Arguments changed to match the old show_menu more: item format and item open arguments are combined. Added ability to pass false for any of the item or menu arguments to get the default. The location to add the class string now must be added manually using the [class] format string. See the readme for details.

2.6.1 (1 May 2006)
Fix for warnings being generated in the PHP error log about array_keys. Fix for an error if there is no menu for the current page (e.g. for search results).

Note: Old releases are stored in the archival directory.

Stats
Powered by Website Baker