User Management 3 (wojilu. Web. Controller. layouts sitelayoutcontroller)

Source: Internet
Author: User

Book connection

This section analyzes the layout method of wojilu. Web. Controller. layouts sitelayoutcontroller.

Public override void layout (){

Load ("topnav", new topnavcontroller (). Index );

View the front-end view in framework \ views \ layouts \ sitelayout \ layout.htmlCodeTake a look

The following code snippet

<Body>

# {Topnav}
<Div id = "pagewrap">
<Div id = "pagewrapinner">

# {Header}

<Div id = "pagemainwrap">

Load ("topnav", new topnavcontroller (). Index );

YesWhat value does topnav assign to variables? Let's take a look at the definition of load.

Protected void load (string sectionname, Aaction action ){
Set (sectionname, loadhtml (Action ));
}

It can be seen that the content of framework \ views \ layouts \ topnav \ index.html is filled and replaced# {Topnav}

Similarly, load ("Header", new topnavcontroller (). header );

Is to fill in the content of framework \ views \ layouts \ topnav \ header.html, replace # {header}

Next, let's take a look at whether topnavcontroller (). Index and framework \ views \ layouts \ topnav \ index.html can be mined.

We can see that the last sentence of topnavcontroller (). index is set ("navurl", T2 (NAV ));

Assign values to the variable # {navurl} at the end of framework \ views \ layouts \ topnav \ index.html. See the following:

<SCRIPT type = "text/JavaScript"> var CTX = NULL;VaR navurl = '# {navurl }'; </SCRIPT>
<SCRIPT type = "text/JavaScript" src = "~ JS/wojilu. Site. topnav. js? V =#{ jsversion} "> </SCRIPT>

For more information, see wojilu. web \ static \ JS \ wojilu. Site. topnav. js.

$ (Document). Ready (function (){

Navurl = (navurl + '? Url = '+ window. Location. href). toajax ();

......

$. Post (navurl, function (data ){

CTX = data;

......

}

Here, the Ajax POST method is used to request the nav action of the server topnavcontroller () again.

Public void NAV (){

// If todo is accessing the user space, judge whether it is a friend or followed.
Echojson (getloginjsonstring ());
}

The NAV () method returns a piece of JSON to the client. Dynamically set user statuses and permissions.

Load ("Header", new topnavcontroller (). header );

It mainly loads the menu and sub-menu of the site. I will discuss it in depth when I have time.

To sum up,The whole process involves two server accesses, one is page loading, and the other is JSON data of the JS request topnav.

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.