Log on to the navigation bar, and navigate to the navigation bar 2015-12-12. Before and after login navigation bar handling, navigation bar Note: add a gray background, about ajax pass value, and js judgment 1 after login controller processing: determine whether to log on and pass the navigation bar before and after logon.
Note: add a gray background for ajax value passing and js judgment.
1. controller processing after login: determine whether to log in and pass user information
Class IndexController extends HomeBaseController {// log on to the public function index () {$ id = I ("get. id "); $ users_model = M (" Users "); $ user = $ users_model-> where (array (" id "=> $ id)-> find (); if (empty ($ user) {$ this-> error ("no such person found! ") ;}$ This-> assign ($ user); $ this-> display (": index ");} function is_login () {if (sp_is_user_login ()) {$ this-> ajaxReturn (array ("status" => 1, "user" => sp_get_current_user ()));} else {$ this-> ajaxReturn (array ("status" => 0, "info" => "this user is not logged on! "));}}
......
2. logon and unlogged display on the homepage navigation bar before and after logon
3. js operations on box after login
Script
$ (Function () {/* control whether the navigation bar shows logon or personal center */$. post ("{: U ('user/index/is_login ')}", {}, function (data) {if (data. status = 1) {if (data. user. avatar) {$ ("# main-menu-user ul li. headicong "). attr ("src", data. user. avatar. indexOf ("http") = 0? Data. user. avatar: "_ UPLOAD _ avatar/" + data. user. avatar) ;}$ ("# main-menu-user ul li. user-nicename "). text (data. user. user_nicename! = ""? Data. user. user_nicename: data. user. user_login); $ ("# main-menu-user. userlogin "). show (); $ ("# main-menu-user. userout "). hide ();} if (data. status = 0) {$ ("# main-menu-user. userout "). show (); $ ("# main-menu-user. userlogin "). hide () ;}}) ;}); script
, Navigation bar Note: add a gray background, about ajax transfer value, and js judgment 1 after login controller processing: determine whether to log on and pass...