comanche: provide an option to add a menu class for different theming choices on some menus (e.g. horizontal, tabbed, etc.)
This commit is contained in:
parent
1857036a99
commit
364fc9f163
@ -79,10 +79,10 @@ function comanche_parser(&$a,$s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function comanche_menu($name) {
|
function comanche_menu($name,$class = '') {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
$m = menu_fetch($name,$a->profile['profile_uid'],get_observer_hash());
|
$m = menu_fetch($name,$a->profile['profile_uid'],get_observer_hash());
|
||||||
return menu_render($m);
|
return menu_render($m,$class);
|
||||||
}
|
}
|
||||||
|
|
||||||
function comanche_replace_region($match) {
|
function comanche_replace_region($match) {
|
||||||
@ -152,13 +152,22 @@ function comanche_widget($name,$text) {
|
|||||||
|
|
||||||
function comanche_region(&$a,$s) {
|
function comanche_region(&$a,$s) {
|
||||||
|
|
||||||
|
|
||||||
$cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER);
|
$cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER);
|
||||||
if($cnt) {
|
if($cnt) {
|
||||||
foreach($matches as $mtch) {
|
foreach($matches as $mtch) {
|
||||||
$s = str_replace($mtch[0],comanche_menu(trim($mtch[1])),$s);
|
$s = str_replace($mtch[0],comanche_menu(trim($mtch[1])),$s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// menu class e.g. [menu=horizontal]my_menu[/menu] or [menu=tabbed]my_menu[/menu]
|
||||||
|
// allows different menu renderings to be applied
|
||||||
|
|
||||||
|
$cnt = preg_match_all("/\[menu=(.*?)\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER);
|
||||||
|
if($cnt) {
|
||||||
|
foreach($matches as $mtch) {
|
||||||
|
$s = str_replace($mtch[0],comanche_menu(trim($mtch[2]),$match[1]),$s);
|
||||||
|
}
|
||||||
|
}
|
||||||
$cnt = preg_match_all("/\[block\](.*?)\[\/block\]/ism", $s, $matches, PREG_SET_ORDER);
|
$cnt = preg_match_all("/\[block\](.*?)\[\/block\]/ism", $s, $matches, PREG_SET_ORDER);
|
||||||
if($cnt) {
|
if($cnt) {
|
||||||
foreach($matches as $mtch) {
|
foreach($matches as $mtch) {
|
||||||
|
@ -24,7 +24,7 @@ function menu_fetch($name,$uid,$observer_xchan) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function menu_render($menu, $edit = false) {
|
function menu_render($menu, $class='', $edit = false) {
|
||||||
if(! $menu)
|
if(! $menu)
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
@ -38,6 +38,7 @@ function menu_render($menu, $edit = false) {
|
|||||||
|
|
||||||
return replace_macros(get_markup_template('usermenu.tpl'),array(
|
return replace_macros(get_markup_template('usermenu.tpl'),array(
|
||||||
'$menu' => $menu['menu'],
|
'$menu' => $menu['menu'],
|
||||||
|
'$class' => $class,
|
||||||
'$edit' => (($edit) ? t("Edit") : ''),
|
'$edit' => (($edit) ? t("Edit") : ''),
|
||||||
'$items' => $menu['items']
|
'$items' => $menu['items']
|
||||||
));
|
));
|
||||||
|
@ -57,7 +57,7 @@ function bookmarks_content(&$a) {
|
|||||||
if($x) {
|
if($x) {
|
||||||
foreach($x as $xx) {
|
foreach($x as $xx) {
|
||||||
$y = menu_fetch($xx['menu_name'],local_user(),get_observer_hash());
|
$y = menu_fetch($xx['menu_name'],local_user(),get_observer_hash());
|
||||||
$o .= menu_render($y,true);
|
$o .= menu_render($y,'',true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ function bookmarks_content(&$a) {
|
|||||||
if($x) {
|
if($x) {
|
||||||
foreach($x as $xx) {
|
foreach($x as $xx) {
|
||||||
$y = menu_fetch($xx['menu_name'],local_user(),get_observer_hash());
|
$y = menu_fetch($xx['menu_name'],local_user(),get_observer_hash());
|
||||||
$o .= menu_render($y,true);
|
$o .= menu_render($y,'',true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<div class="pmenu">
|
<div class="pmenu{{if $class}} {{$class}}{{/if}}">
|
||||||
{{if $menu.menu_desc}}
|
{{if $menu.menu_desc}}
|
||||||
<h3 class="pmenu-title">{{$menu.menu_desc}}</h3>
|
<h3 class="pmenu-title">{{$menu.menu_desc}}</h3>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
Reference in New Issue
Block a user