Post-login navigation bar handling, navigation bar 2015-12-12_PHP tutorial-php Tutorial

Source: Internet
Author: User
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

  • Register
  • Login

  • Exit

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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.