GetSimple Support Forum
Admin slide menu - remember state - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Developer Discussions (http://get-simple.info/forums/forumdisplay.php?fid=8)
+--- Thread: Admin slide menu - remember state (/showthread.php?tid=3220)



Admin slide menu - remember state - bogyvet - 2012-05-25

I'm working on one user plugin so I have on plugin Administration - slide navigation and page navigation on each page.
Problem was that slide menu didn't remember state when I call any of pages from page navigation. I solve this problem and I hope that someone can use this.


I add action to plugin slide bar menu item.

Quote:add_action($thisfile.'-sidebar','createSideMenuState',array($thisfile,'User Management', array('users_statistic', 'create_user', 'user_list', 'search_user', 'user_comments', 'user_files')));

'users_statistic', 'create_user', 'user_list', 'search_user', 'user_comments', 'user_files'
are navigation inside User Management page.

eg.
Quote:/admin/load.php?id=TIDE_users&users_statistic

I didn't change core but I add 2 functions into admin/inc/plugin_functions.php:
Quote:/**
* Create Side Menu (Modification) - remember state when you are calling submenus
*
* This adds a side level link to a control panel's section
* @param string $id of the link you are adding
* @param string $txt Text to add to tabbed link
* @param array $action
* @param bool $always
*/
function createSideMenuState($id, $txt, $action=null, $always=true){
$current = false;

if(is_array($action)){
$check_action = check_array($action);

if ($check_action) {
$current = true;
}

}
if ($always || $current) {
echo '<li id="sb_'.$id.'"><a href="load.php?id='.$id.($action[0] ? '&amp;'.$action[0] : '').'" '.($current ? 'class="current"' : '').' >'.$txt.'</a></li>';
}
}

/**
* Find action in address
*
* @param array $action
* @return multitype:
*/
function check_array($action){
$action = array_flip($action);
$data = array_intersect_key($action, $_GET);
return $data;
}



I hope that this would help to someone.