开发者

What's the meaning of $_REQUEST['page'] in Drupal?

开发者 https://www.devze.com 2023-02-14 13:50 出处:网络
What is the meaning of $_REQUEST[\'page\'], and this line $total 开发者_如何学Go= $GLOBALS[\'pager_total_items\'][0];

What is the meaning of $_REQUEST['page'], and this line

$total 开发者_如何学Go= $GLOBALS['pager_total_items'][0];

in Drupal 6?


What Phil has given is with respect to the normal php.

In the context of Drupal however they have a different meaning.

In Drupal if you are trying to create a listing with the pager, the $_REQUEST['page'] is set to signify that it is a pager display, and the value signifies the current page number you are viewing.

So if you assume that there are 10 items in a every page, you can use something like

if($_GET['page']){
    $first_in_this_page = ($_GET['page']*10)+1;
}

to get the number of the first item in the page.

And I think $_GLOBALS['pager_total_items'][0] can be used in place of 10(that is number of items in a page) However I am not sure about $_GLOBALS['pager_total_items'][0], but I am sure about the first one.


$_REQUEST['page'] retrieves the value of the "page" item in any of the $_GET, $_POST or $_COOKIE super global arrays, whichever provides a hit first (in PHP 5.3, order depends on the request_order directive).

$_GLOBALS['pager_total_items'][0] is referencing a potential global variable $pager_total_items that appears to be an array. The [0] is referring to the first item (or first character if it's a string).

Presumably, these variables are set / populated elsewhere. I can't provide anything relating to the drupal context.

0

精彩评论

暂无评论...
验证码 换一张
取 消