class GenericTemplateGlobalProvider implements TemplateGlobalProvider (View source)

Properties

public static array $modules

Methods

public static 
array
get_template_global_variables()

Called by SSViewer to get a list of global variables to expose to the template, the static method to call on this class to get the value for those variables, and the class to use for casting the returned value for use in a template

public static 
string
ModulePath(string $name)

Given some pre-defined modules, return the filesystem path of the module.

public static 
getDataList($className)

This allows templates to create a new DataList from a known DataObject class name, and call methods such as aggregates.

Details

static array get_template_global_variables()

Called by SSViewer to get a list of global variables to expose to the template, the static method to call on this class to get the value for those variables, and the class to use for casting the returned value for use in a template

If the method to call is not included for a particular template variable, a method named the same as the template variable will be called

If the casting class is not specified for a particular template variable, ViewableData::$default_cast is used

The first letter of the template variable is case-insensitive. However the method name is always case sensitive.

Return Value

array

Returns an array of items. Each key => value pair is one of three forms:

  • template name (no key)
  • template name => method name
  • template name => array(), where the array can contain these key => value pairs
    • "method" => method name
    • "casting" => casting class to use (i.e., Varchar, HTMLText, etc)

static string ModulePath(string $name)

Given some pre-defined modules, return the filesystem path of the module.

Parameters

string $name

Name of module to find path of

Return Value

string

static DataList getDataList($className)

This allows templates to create a new DataList from a known DataObject class name, and call methods such as aggregates.

The common use case is for partial caching:

<% cached List(Member).max(LastEdited) %>
    loop members here
<% end_cached %>

Parameters

$className

Return Value

DataList