Search code examples
phpdrupaldrupal-6

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


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

$total = $GLOBALS['pager_total_items'][0];

in Drupal 6?


Solution

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