Created
November 27, 2013 08:21
-
-
Save Ulv/7672350 to your computer and use it in GitHub Desktop.
maxsite cms функция вывода меню
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* вывод меню | |
* | |
* Пример: | |
* | |
* <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