newbie LAC Posted July 31, 2017 Posted July 31, 2017 Hello, 1. Any reason why you use duplicate code in appmenu template? applications/core/dev/html/admin/global/appmenu.phtml {{if count( $item ) > 1}} <li data-menuKey='{$appAndModule}'> <h3>{lang="menu__{$appAndModule}"}</h3> <ul class='ipsList_reset'> {{foreach $item as $key => $url}} <li> {{$badgeNumber = NULL; try { $badgeNumber = \IPS\Application::load( mb_substr( $appAndModule, 0, mb_strpos( $appAndModule, '_' ) ) )->acpMenuNumber( $url ); } catch( \Exception $ex ){ } }} {{if $badgeNumber}} <a href='{url="$url"}'> {lang="menu__{$appAndModule}_{$key}"} <span class='ipsNotificationCount'>{$badgeNumber}</span> </a> {{else}} <a href='{url="$url"}'>{lang="menu__{$appAndModule}_{$key}"}</a> {{endif}} </li> {{endforeach}} </ul> </li> {{else}} <li data-menuKey='{$appAndModule}'> <h3>{lang="menu__{$appAndModule}"}</h3> <ul class='ipsList_reset'> {{foreach $item as $key => $url}} <li> {{$badgeNumber = NULL; try { $badgeNumber = \IPS\Application::load( mb_substr( $appAndModule, 0, mb_strpos( $appAndModule, '_' ) ) )->acpMenuNumber( $url ); } catch( \Exception $ex ){ } }} {{if $badgeNumber}} <a href='{url="$url"}'> {lang="menu__{$appAndModule}_{$key}"} <span class='ipsNotificationCount'>{$badgeNumber}</span> </a> {{else}} <a href='{url="$url"}'>{lang="menu__{$appAndModule}_{$key}"}</a> {{endif}} </li> {{endforeach}} </ul> </li> {{endif}} 2. Also pay attention to {{$totalBadge = 0;}} {{foreach $items as $appAndModule => $item}} {{foreach $item as $key => $url}} {{$badgeNumber = NULL; try { $badgeNumber = \IPS\Application::load( mb_substr( $appAndModule, 0, mb_strpos( $appAndModule, '_' ) ) )->acpMenuNumber( $url ); } catch( \Exception $ex ){ } }} {{if $badgeNumber}} {{$totalBadge += $badgeNumber;}} {{endif}} {{endforeach}} {{endforeach}} If we move <ul> block (<ul class='ipsList_reset ipsScrollbar ipsScrollbar_light'>) above <a> (<a href='{url="$menu['defaults'][$tab]"}'>) we can count the $totalBadge in <ul> 3. Also it will be useful to highlight a menu item where we located Something like
teraßyte Posted July 31, 2017 Posted July 31, 2017 That code in your first codebox must be some leftover. I guess they were handling single items in a special manner at some point, but at some point fixed it to be the same. But yeah, that piece of code is a completely useless duplicate I also like your idea #3.
bfarber Posted August 1, 2017 Posted August 1, 2017 I've removed the duplicate code but haven't made any other changes yet.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.