menu (Smarty extension function)

{menu} is a custom Smarty function for the construction of menus. A menu, in this context, is a set of links and text for a specific function. For example, if you are signed in, the bottom of this page has a menu with various items such as "New Comment" and "Send Feedback." If you are the owner of a page, there are even more options like "Edit" and "Delete." These menus are all created with the {menu} function.

Syntax:

{menu name="string" [ link="url" text="string" sep="string" sort=boolean prefix="string" suffix="string" ] }

{menu} is used in two ways: first, to construct a menu in memory, and, second, to insert the menu onto a page. When {menu} is invoked with the text= parameter, it adds the text item (and optionally the associated link URL) to the named menu. When invoked without the text= parameter, it inserts the named menu into the specific location. An example here might help:

{menu name="sample" text="News" link="http://news.yahoo.com"}
{menu name="sample" text="Sports" link="http://sports.yahoo.com"}
{menu name="option" text="Search" link="http://search.yahoo.com"}
<ul>{menu name="Sample" prefix="<li>" suffix="</li>" sort=true}</ul>

In this example, the first two lines add links (News and Sports) to the menu "sample." The third line adds an item "Search" to a different menu named "option." Finally, the last line inserts the menu as a list between the <ul> and </ul> tags. Note that the "option" menu does not yet appear on the page.

{menu} parameters:

One of the advantages of using {menu} over hard-coding menus is that the menu items can be added throughout your code, and then inserted all together, much as the action menus on the bottom of these pages are.