Take care of thinkphp. Page _php Tutorial

Source: Internet
Author: User
Thinkphp is nothing to say, a lightweight PHP MVC framework; the other day to engage in this thing, made a photo album, found that its pagination is very confusing, especially with the page.

Follow its manual to get it, not much effect; Later, it is not very complicated to look directly at its pagination class. Understand its principle, just is the $where array of parameters, separated, in the way of get, passed to the paging class, and then combine these parameters into the query statement, the implementation of the parameter page. It is then discovered that the $where array is passed in the same way as the name value in the form to do so. Otherwise, passed over, to the next page, is not received.

Another problem, $where array, is that you can have arrays, like $p=array (' eq ', $kid), the variable $p added to the $where, the separation of parameters directly according to the manual, seems to have no effect. To solve this problem, we write a function that determines if it is an array and then detaches, which is equivalent to a recursive.

Another problem is that when the page is connected, will automatically add the operation name of this page, that is, it is/index/pager/words, pagination, will become/index/pager/pager, which also let me tangled, do not know why.

In the end, there is no way to do it in the manual. Think, is not to pass the parameters of the past, it needs to be so tangled. Modified its show () function, remove the URL parameter filtering this function, directly is the paging, for example, the page is/index/pager, then, using Ushow ("/index/pager") (modified), Get/index/pager/ &p=2, it is clear that p=2 is the second page. This can also be used for pagination without parameters. In fact, I just think it's a bit of a tangled page, and when I haven't written the page, I've modified the function, right here. Then, is to put the required parameters in the action inside the Assembly, passed to the front desk, to the foreground where it must be javascript inside. This parameter is then added to the tab after the page is paged; part of the Code:

$show = $Page->ushow (__url__. ") /". $_request[c (Var_action)]." /"); (call the post-assembly paging function, in effect, wrap it up, open it, and handle it yourself.) )

$output = "/kid/". $kid. " /spbegintime/". $p [" Spbegintime "]." /spendtime/". $p [" Spendtime "]." /spname/". $p [" Spname "]; (action, assemble paging parameters, or you can use & to distinguish parameters.) )

$this->assign (' Outpager ', $output); Bind page variable.

$ ("#pager a"). Click (function () {
var i=$ ("#pager a"). Index (this);
$ ("#pager a"). EQ (i). attr ("href", $ ("#pager a"). EQ (i). attr ("href") + "{$outpager}");
}); The foreground modifies the connection address and adds the parameters.

Recently TP out of 2.1, not to see, hey. Feel it, sometimes with such a framework, will not get used to, seems to be less a feeling. As with JQ, it is sometimes customary for $ ("form"). Submit (), but in fact, the page one or two in the use of JS, did not load the JQ in, I have been thinking, will not use JQ, let me put ordinary js to forget? This may be one of the goals of JQ, haha. Of course, as a developer, you can't just confine yourself to a frame, a language.

Recently work changed ccmall.cn also tangled, often is the local changed, uploaded to the server, it is useless; no way, the server I do not have permission to modify, I have to change the right to upload, the above people to modify the server. Cough..

Sometimes think, like ccmall.cn such a large B2B,B2C website, do success, every day at least to withstand tens of thousands of IP, hundreds of thousands of times PV, such a subject, get practical use, will there be problems? After all, the gap between the project and the actual application of the university is very large. Also, in the project, will be a lot of, originally the most basic HTML tags, encapsulated into so complex server-side control, generate a lot of viewstate, and then modify the time, on N trouble. Is it necessary? In the process of modification, often found that, sometimes, spend a lot of effort to write a server-side control, a place to use, to achieve the function, can be a few very basic JS and simple HTML tags to be done. Cough..

Look at some of the PHP project, it is still the kind of simple and clear, concise, not bloated. Microsoft likes to treat others as fools and encapsulate everything. (This refers only to ASP.) Of course, is not to say that ASP. Ha, just feel that many people do not have the correct use of ASP. In fact, the strong type of. NET, the compiled type, and the generics, ADO, and so on are all very good, as well as the later launch of ASP. Some of the new features introduced after net3.0, like SQL CLR, are very useful for logical database operations.

Wordy a lot, just a long time no write, hey. Some of the above views are just some of the personal opinions ha, if you do not agree, big can not retwist ha, welcome to shoot bricks.

http://www.bkjia.com/PHPjc/364672.html www.bkjia.com true http://www.bkjia.com/PHPjc/364672.html techarticle thinkphp is nothing to say, a lightweight PHP MVC framework; the other day to engage in this thing, made a photo album, found that its pagination is very confusing, especially with the page. ...

  • Related Article

    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.