Template


All template actions (such as displaying a view) are performed through the template library.


Properties

No public properties available.


show()

Display a specific template.

If the request contains zaj_pushstate_block, it will reroute to block. See Outlast Framework pushState support for more info.

$this->zajlib->template->show($source_path, $force_recompile = false, $return_contents = false, $custom_compile_destination = false)

@param string $source_path The path to the template to be compiled relative to the active view folders.
@param boolean $force_recompile If set to true, the template file will be recompiled even if a cached version already exists. (False by default.)
@param boolean $return_contents If set to true, the compiled contents will be returned by the function and not sent to the browser (as is the default).
@param boolean $custom_compile_destination If set, this allows you to compile the template to a different location than the default. This is not recommended unless you really know what you are doing!
@return string|boolean If requested by the $return_contents parameter, it returns the entire generated contents. Otherwise returns true.

block()

Extracts a specific block from a template and displays only that. This is useful for ajax requests.

If the request contains zaj_pushstate_block, it will display that block. See Outlast Framework pushState support for more info.

$this->zajlib->template->block($source_path, $block_name, $recursive = false, $force_recompile = false, $return_contents = false)

@param string $source_path The path to the template to be compiled relative to the active view folders.
@param string $block_name The name of the block within the template.
@param boolean $recursive If set to true (false by default), all parent files will be checked for this block as well.
@param boolean $force_recompile If set to true, the template file will be recompiled even if a cached version already exists. (False by default.)
@param boolean $return_contents If set to true, the compiled contents will be returned by the function and not sent to the browser (as is the default).
@return bool|string Returns the contents if requested or false if failure.

download()

This function will push the contents of the template to the user as a downloadable file. Useful for generating output like xml, csv, etc. The method will exit after execution is finished.

$this->zajlib->template->download($source_path, $mime_type, $download_file_name, $force_download=true, $force_recompile=false)

@param string $source_path Path to the template file.
@param string $mime_type The mime type by which to initiate the download.
@param string $download_file_name The file name to use for this download.
@param bool $force_download If set to true, the content will never be displayed within the browser. True is the default and the recommended setting.
@param bool $force_recompile If set to true, the template will always be forced to recompile. Defaults to false.

ajax()

Will return the output as an ajax response, setting the appropriate headers.

$this->zajlib->template->ajax($source_path, $block_name = false, $force_recompile = false)

@param string $source_path The path to the template to be compiled relative to the active view folders.
@param bool|string $block_name If specified, only this block tag of the template file will be returned in the request.
@param boolean $force_recompile If set to true, the template file will be recompiled even if a cached version already exists. (False by default.)
@return boolean Will return true if successful.

email()

Emails the template in an HTML format and returns true if successful.

@param string $source_path The path to the template to be compiled relative to the active view folders.
@param string $from The email which is displayed as the from field.
@param string $to The email to which this message should be sent.
@param string $subject A string with the email’s subject.
@param string $sendcopyto If set, a copy of the email will be sent (bcc) to the specified email address. By default, no copy is sent.
bool|array $additional_headers Any additional email headers you may want to send defined as a key/value pair.
bool|string $plain_text_version The path to the template to be compiled for the plain text version.
bool|integer $send_at Unix timestamp of the delayed sending or false if no delay is needed
@return bool Will return true. Depending on the email gateway implementation it may return false if the email failed.

exists()

Returns true if a template file exists anywhere in the available paths based on the source path. Same as $this->zajlib->compile->source_exists().

@param string $source_path The source path to check for.
@return boolean Returns true if found, false if not.

get_variables()

Returns an object containing the {{ofw.*}} built-in variables that are available to the template.

$this->zajlib->template->get_variables()

@return stdClass An object with the zaj variables.

Outlast Web & Mobile Development (c) 2023 | Privacy Policy |