public method

Executes a named rendering process by running each process step in sequence and aggregating the results. The View class comes with 3 built-in processes: 'all', 'template', and 'element'. The 'all' process is the default two-step rendered view, where a template is wrapped in a layout containing a header and footer.


  • string $process

    A named set of rendering steps defined in the $_processes array.

  • array $data

    An associative array of data to be rendered in the set of templates.

  • array $options

    Options used when rendering. Available keys are as follows:

    • 'type' string: The type of content to render. Defaults to 'html'.
    • 'layout' string: The name of the layout to use in the default two-step rendering process. Defaults to null.
    • 'template' string: The name of the template to render. Defaults to null.
    • 'context' array: An associative array of information to inject into the rendering context.
    • 'paths' array: A nested array of paths to use for rendering steps. The top-level keys should match the 'path' key in a step configuration (i.e.: 'template', 'layout', or 'element'), and the second level is an array of path template strings to search (can be a string if there's only one path). These path strings generally take the following form: '{:library}/views/{:controller}/{:template}.{:type}.php'. These template strings are specific to the File loader, but can take any form useful to the template loader being used.



Returns the result of the rendering process, typically by rendering a template first, then rendering a layout (using the default configuration of the 'all' process).


	public function render($process, array $data = [], array $options = []) {
		$defaults = [
			'type' => 'html',
			'layout' => null,
			'template' => null,
			'context' => [],
			'paths' => [],
			'data' => []
		$options += $defaults;

		$data += $options['data'];
		$paths = $options['paths'];
		unset($options['data'], $options['paths']);
		$params = array_filter($options, function($val) { return $val && is_string($val); });
		$result = null;

		foreach ($this->_process($process, $params) as $name => $step) {
			if (isset($paths[$name]) && $paths[$name] === false) {
			if (!$this->_conditions($step, $params, $data, $options)) {
			if ($step['multi'] && isset($options[$name])) {
				foreach ((array) $options[$name] as $value) {
					$params[$name] = $value;
					$result = $this->_step($step, $params, $data, $options);
			$result = $this->_step((array) $step, $params, $data, $options);
		return $result;