Docs: Page Variables

Every page has built-in variables that you can use. They include:

$_PAGE['page'] (or $_PAGE['id'])
$_PAGE['title']
$_PAGE['subsection']
$_PAGE['category_id'] (category and product pages)
$_PAGE['category']
$_PAGE['subcategory']
$_PAGE['subsubcategory']
$_PAGE['custom_head']
$_PAGE['custom_text']
$_PAGE['description'] (sets meta description)
$_PAGE['keywords'] (sets meta keywords)
$_PAGE['product_id'] (product pages)

Here is an example of using the $_PAGE['custom_text'] variable to display text only on the cart page:

<?
if($_PAGE['page']=='order'){
      $_PAGE['custom_text'] = "<p>When you are ready to pay for your order click the <a href=\"/checkout/\">checkout</a> button.</p>";
}
?>

The $_PAGE['page'] variable can be idenntified by viewing any page and locating the id attribute of the body tage. Normally the id will mirror the page URL, so the body tag of the URL /shop/books/ will look like <body id="page-books" ... >

Similarly, the page variables for $_PAGE['subsection'] and $_PAGE['subsection'] are used in the body classes. So the books category would have the body class:

<body id="page-books" class="category-books" ... >

 

Revisions history (7)    ( hide | show )     Variables > Page Variables

×