Pager::factory

Pager::factory() – Creates a pager instance

Synopsis

require_once 'Pager.php';

object &factory ( array $options )

Parameter

Pager::factory() method takes an associative array of parameters as input values. This is the complete list of these options:

  • itemData [array]

    Array of items to page.

  • totalItems [integer]

    Number of items to page (used only if itemData is not provided).

  • perPage [integer]

    Number of items to display on each page.

  • delta [integer]

    Number of page numbers to display before and after the current one.

  • mode [string]

    "Jumping" or "Sliding" -window - It determines pager behaviour.

  • httpMethod [string]

    Specifies the HTTP method to use. Valid values are 'GET' or 'POST'.

  • formID [string]

    Specifies which HTML form to use in POST mode.

  • importQuery [boolean]

    if true (default behaviour), variables and values are imported from the submitted data (query string) and used in the generated links, otherwise they're ignored completely

  • currentPage [integer]

    Initial page number (if you want to show page #2 by default, set currentPage to 2)

  • expanded [boolean]

    if TRUE, window size is always 2*delta+1

  • linkClass [string]

    Name of CSS class used for link styling.

  • urlVar [string]

    Name of URL var used to indicate the page number. Default value is "pageID".

  • path [string]

    Complete path to the page (without the page name).

  • fileName [string]

    name of the page, with a "%d" if append == TRUE.

  • fixFileName [boolean]

    If set to FALSE, the fileName option is not overridden. Use at your own risk.

  • append [boolean]

    If TRUE pageID is appended as GET value to the URL. If FALSE it is embedded in the URL according to fileName specs.

  • altFirst [string]

    Alt text to display on the link of the first page. Default value is "first page"; if you want a string with the page number, use "%d" as a placeholder (for instance "page %d")

  • altPrev [string]

    Alt text to display on the link of the previous page. Default value is "previous page";

  • altNext [string]

    Alt text to display on the link of the next page. Default value is "next page";

  • altLast [string]

    Alt text to display on the link of the last page. Default value is "last page"; if you want a string with the page number, use "%d" as a placeholder (for instance "page %d")

  • altPage [string]

    Alt text to display before the page number. Default value is "page " (followed by the page number). You can optionally use "%d" as a placeholder (for instance "page n. %d") to place the page number where you want.

  • prevImg [string]

    Something to display instead of "<<". It can be text such as "<< PREV" or an <img/> as well.

  • nextImg [string]

    Something to display instead of ">>". It can be text such as "NEXT >>" or an <img/> as well.

  • separator [string]

    What to use to separate numbers. It can be an <img/>, a comma, an hyphen, or whatever.

  • spacesBeforeSeparator [integer]

    Number of spaces before the separator.

  • spacesAfterSeparator [integer]

    Number of spaces after the separator.

  • firstLinkTitle [string]

    String used as title in <link rel="first"> tag

  • nextLinkTitle [string]

    String used as title in <link rel="next"> tag

  • prevLinkTitle [string]

    String used as title in <link rel="previous"> tag

  • lastLinkTitle [string]

    String used as title in <link rel="last"> tag

  • curPageLinkClassName [string]

    CSS class name for the current page link.

  • curPageSpanPre [string]

    Text before the current page link.

  • curPageSpanPost [string]

    Text after the current page link.

  • firstPagePre [string]

    String used before the first page number. It can be an <img/>, a "{", an empty string, or whatever.

  • firstPageText [string]

    String used in place of the first page number.

  • firstPagePost [string]

    String used after the first page number. It can be an <img/>, a "}", an empty string, or whatever.

  • lastPagePre [string]

    Similar to firstPagePre, but used for last page number.

  • lastPageText [string]

    Similar to firstPageText, but used for last page number.

  • lastPagePost [string]

    Similar to firstPagePost, but used for last page number.

  • clearIfVoid [boolean]

    if there's only one page, don't display pager links (returns an empty string).

  • extraVars [array]

    additional URL vars to be added to the querystring.

  • excludeVars [array]

    URL vars to be excluded from the querystring.

  • useSessions [boolean]

    if TRUE, number of items to display per page is stored in the $_SESSION[$_sessionVar] var.

  • closeSession [boolean]

    if TRUE, the session is closed just after R/W.

  • sessionVar [string]

    Name of the session var for perPage value. A value different from default can be useful when using more than one Pager istance in the page.

  • showAllText [string]

    Text to be used for the 'show all' option in the select box generated by getPerPageSelectBox()

  • pearErrorMode [constant]

    PEAR_ERROR mode for raiseError(). Default is PEAR_ERROR_RETURN.

REQUIRED options are:

  • fileName IF append==FALSE (default is TRUE)

  • itemData OR totalItems (if itemData is set, totalItems is overwritten)

Return value

object - a specific Pager instance or a PEAR_Error object, if fails