Variables and Functions
Lists of variables, classes, functions, and so on defined by HS-CMS are listed below, but first, we discuss conventions.
Conventions
Global variables, classes, and functions tend to follow these conventions:
- Start with
HS_and then follow normal conventions:- Classes
CapitalizedLikeThis - Most variables and keys are
capitalizedLikeThis— ex:$HS_siteDir,$HS_requestUrl. Notice the standard of capitalizing acronyms like URL and ID as if they were normal words! If that’s confusing, remember it’s just like JavaScript’sdocument.getElementById. - Variables and array keys whose names are taken from database fields
are
capitalized_like_this, just like the database column names. ex:$HS_page['robot_friendly'] - Functions
capitalized_like_this()-- if the typing underscores bothers you, consider typing with Dvorak.
- Classes
- Global constants are really members of a global array variable
Global Variables, Arrays, and Objects (not classes)
$HS_installationDir
The current installation root, containing "sites," "doc," "core," "filters," and the other directories. This variable is defined like this in page.php:
$HS_installationDir = realpath("..").DIRECTORY_SEPARATOR;
and is thus available to every file except for config_installation.php. (If that’s a problem, contact Alan Hogan and complain, but it shouldn’t be one.)
$HS_siteDir
String with the path to the current site’s directory, including the trailing slash. Example value:
/users/username/homepages/hs-cms/welcome/,
/path/to/hs-cms/example/. Example usage: REQUIRE_ONCE $HS_siteDir.'config_site.php';
HS_requestUrl
String with the current request URI without beginning or trailing slashes (except for the root,
in which case this variable holds just a slash, '/') and without any GET variables.
Example
Browser address: <code>http://example.com/some/page/?foo&bar=1</code>
$_ENV['REQUEST_URI']: <code>/some/page/?foo&bar=1</code>
HS_requestUrl: <code>some/page</code>
$HS_page[]
An array available to render engines. It’s based on the original page information in the database, but by the time it reaches the render engine, it’s no longer the raw data. Details follow.
This array has the following keys:
- $HS_page[‘content’]
-
When applying formatting and cache, this is somewhere between the original, unformatted (e.g. still Markdown) content and the final XHTML (assuming you are outputting XHTML).
By the time it’s in the rendering engine, it’s the final product, ready to
print()into the document. - $HS_page[‘title’]
-
String, content title, plaintext (entities need encoded by render engine).
- $HS_page[‘description’]
-
Description, appropriate for being displayed in a list of pages and for inclusion in the pages’s
data. Still plaintext (entities need encoded by render engine).
$HS_page[]
:
