Skip to content
postpostmodern edited this page Sep 12, 2010 · 5 revisions

The following list of functions is applicable to the v1 branch. Most of these are methods of the Helper class in v2, accessible via the $helper object in your templates and pages. The Helper class is found in phooey/system/inc/PhooeyHelper.class.php

Phooey has a bunch of built-in functions that act as helpers or template tags. This page documents most of them.

string active_nav_class(string $link)

Returns ’ active ’ if $link matches the current url. Returns ’ parent ’ if the current url is a child of $link.

string body_class()

Returns a list of css class names based on the current path separated by spaces.

string css_tags()

Returns css link tags based on the css array in the yaml config.

string description()

Returns the page’s description based on the description declaration in the yaml config for the meta_tags() helper.

string doctype()

Returns the page’s doctype based on the doctype declaration in the yaml config for the doctype_tag() helper.

string doctype_tag()

Returns the doctype declaration tag.

string google_analytics()

Returns the GA Javascript code if google_analytics_id is declared in the yaml config. (Otherwise, it returns a blank string.)

string google_jsapi()

Returns links to various Javascript libraries provided by the Google AJAX Libraries API.

h(string $string)

Outputs escaped string (do not use echo with this function). It’s a shortcut for echo htmlspecialchars($string);.

string html_tag()

Returns the appropriate <html> opening tag depending on the doctype.

bool isvar(string $varname)

Returns true if the given string is an element of the $vars array.

bool is_xhtml()

Returns true if the page’s doctype specifies XHTML (used by tag_closer()).

string js_tags()

Returns script tags that link to various Javascript files as specified in the js declaration in the yaml config.

string keywords()

Returns the keywords declared in the yaml config.

string lang()

Returns language declared in the yaml config (or default: en).

string meta_tags()

Returns the meta tags specified by the meta declaration in the yaml config. See Configuration Options for the defaults.

string name(string $page_path)

Returns the name of the page based on the url (the part of the url after the last slash).

string nav_list(int $depth=1000, string $parent=false)

Returns an unordered list with sublists depending on the $depth. Pass the $parent path to get subnav. The ul has all sorts of additional features such as ‘active’ class for the active li and a tags, ‘parent’ class for the parent of the current page, etc.

string parent(string $page_path)

Returns the path to one level above the current url.

string render_content(string $file)

An alias for render_page().

string render_page(string $file)

Includes a .page file from the content directory.

string render_part(string $file)

Includes a .part file from the templates directory.

string tag_closer()

Returns ’ /’ or an empty string depending on whether or not the doctype is XHTML or HTML.

string title(string $separator = ‘:’)

Returns the page title by combining the site_title with the page title joined with $separator.

string title_tag()

Returns the <title> tag containing the value of the title() helper.

bool varset(string $varname)

Returns true if the specified element of $vars is set to a non-empty value.