*
  • * * *
  • * ... * * * * @param $params array - look up the bellow example * @param $smarty * @return string - generated HTML code * *
     * smarty_function_sugar_menu(array(
     *      'id' => $string, //id property that is applied in root UL
     *      'items' => array(
     *          array(
     *              'html' => $html_string, //html container that renders in the LI tag
     *              'items' => array(), //nasted ul lists
     *          )
     *      ),
     *      'htmlOptions' => attributes that is applied in root UL, such as class, or align.
     *      'itemOptions' => attributes that is applied in LI items, such as class, or align.
     *      'submenuHtmlOptions' => attributes that is applied in child UL, such as class, or align.
     * ), $smarty);
     *
     * 
    * * @author Justin Park (jpark@sugarcrm.com) */ require_once('include/SugarHtml/SugarHtml.php'); function smarty_function_sugar_menu($params, &$smarty) { $root_options = array( "id" => array_key_exists('id', $params) ? $params['id'] : "" ); if(array_key_exists('htmlOptions', $params)) { foreach($params['htmlOptions'] as $attr => $value) { $root_options[$attr] = $value; } } $output = SugarHtml::createOpenTag("ul", $root_options); foreach($params['items'] as $item) { if(strpos($item['html'], " $item['items'], 'htmlOptions' => !empty($params['submenuHtmlOptions']) ? $params['submenuHtmlOptions'] : array() ), $smarty); } $output .= SugarHtml::createCloseTag("li"); } $output .= SugarHtml::createCloseTag("ul"); return $output; }