Global Variables

BigTree exposes a number of global variables that may be useful in your templates, callouts, and modules.

  • $bigtree — The main container for internal BigTree variables. It contains the following useful keys:
    • "path" — An array of routes in the current URL string (i.e. would return an array with "about" and "cookies").
    • "commands" — An array containing routes in the URL string that could not be matched to a page that are available to a routed template. For more information on how "commands" is generated, visit the page on Routed Templates.
    • "config" — The configuration array set in /templates/config.php
    • "preview" — Indicates whether the user is previewing a page in the front end.
    • "page" — The currently delivered page array from bigtree_pages
    • "resources" — Decoded resources for the current page
    • "callouts" — Decoded callouts for the current page
    • "layout" — The layout to load a template's content to (available to set in templates)
    • "content" — The content generated by the template (available only in layouts)
  • $cms — An instance of the BigTreeCMS class.
  • $admin — An instance of the BigTreeAdmin class (only defaults to available inside the admin).
  • $domain — The domain for the site (without a trailing slash, i.e.
  • $www_root — Contains the URL for the homepage of your site.
  • $static_root — The root from which static content should be served (images, flash, css and javascript that aren't parsed).
  • $secure_root — Contains the URL for the homepage of the site with http:// replaced with https://
  • $server_root — Contains the file system path for the / folder of your site.
  • $site_root — Contains the file system path for the /site/ folder of your site.
  • $admin_root — Contains the URL for the homepage of the admin area (only available from within the admin).

Defined Constants

Many of the global variables are also defined as constants to ensure that they are not overwritten by included scripts.

  • DOMAIN = $domain
  • WWW_ROOT = $www_root
  • STATIC_ROOT = $static_root
  • SECURE_ROOT = $secure_root
  • SERVER_ROOT = $server_root
  • SITE_ROOT = $site_root
  • ADMIN_ROOT = $admin_root (only available in the admin).
  • BIGTREE_PREVIEWING = $bigtree["preview"]

Static vs. WWW Roots

BigTree 4.0 beta 6 introduces $static_root and STATIC_ROOT as available global variables. These variables are equivalent to the value set for $bigtree["config"]["static_root"] in ~/templates/config.php. The purpose of STATIC_ROOT is two-fold:

  1. For sites using Basic routing through /index.php/, STATIC_ROOT is required for serving up static, non-parsed content (images, flash, css, javascript) that resides in the ~/site/ folder. Parsed CSS and JavaScript should still be served through WWW_ROOT/css/ and WWW_ROOT/js/ (so that the URL ends up being /index.php/css/whatever.css).
  2. For sites that want to use a different domain to help with the maximum connections per domain limit, you can change the default static root to point to whatever domain you want that points to the same web root.

In general, if you are not using "Basic" non-rewrite routing you can completely ignore STATIC_ROOT and stick with WWW_ROOT. If you are using "Basic" routing, use STATIC_ROOT whenever referencing a static file (image, download, etc).