Skip to content

Instantly share code, notes, and snippets.

@Ulv
Created November 27, 2013 08:21
Show Gist options
  • Save Ulv/7672350 to your computer and use it in GitHub Desktop.
Save Ulv/7672350 to your computer and use it in GitHub Desktop.
maxsite cms функция вывода меню
/**
* вывод меню
*
* Пример:
*
* <code>
* if ($menu = mso_get_option('top_menu', 'templates', '')) {
* echo limo_menu_out($menu);
* }
* </code>
* @author Vladimir Chmil <[email protected]>
* @param string $menu строка меню из базы maxsite
*/
function limo_menu_out($menu)
{
$menu_list = "";
$menu = explode("\n", trim($menu));
$current_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
foreach ($menu as $elem) {
$elem = explode('|', $elem);
if (count($elem) > 1) {
$url = trim($elem[0]); // адрес
$name = trim($elem[1]); // название
if ($url == $current_url) $class = ' class="selected"';
else $class = '';
$menu_list .= '<li' . $class . '><a href="' . $url . '"><span>'
. $name . '</span></a></li>' . NR;
}
}
return $menu_list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment