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. http://www.website.com/about/cookies/ 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. http://www.website.com)
- $www_root — Contains the URL for the homepage of your site.
- $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).
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 as available global variables. These variables are equivalent to the value set for
~/templates/config.php. The purpose of
STATIC_ROOT is two-fold:
WWW_ROOT/js/(so that the URL ends up being
- 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).