Class Phalcon\Mvc\View\Simple

extends abstract class Phalcon\Di\Injectable

implements Phalcon\Events\EventsAwareInterface, Phalcon\Di\InjectionAwareInterface

This component allows to render views without hicherquical levels

  1. <?php
  2. $view = new \Phalcon\Mvc\View\Simple();
  3. echo $view->render('templates/my-view', array('content' => $html));
  4. //or with filename with extension
  5. echo $view->render('templates/my-view.volt', array('content' => $html));

Methods

public getRegisteredEngines ()

public __construct ([unknown $options])

Phalcon\Mvc\View\Simple constructor

public setViewsDir (unknown $viewsDir)

Sets views directory. Depending of your platform, always add a trailing slash or backslash

public string getViewsDir ()

Gets views directory

public registerEngines (unknown $engines)

Register templating engines

  1. <?php
  2. $this->view->registerEngines(array(
  3. ".phtml" => "Phalcon\Mvc\View\Engine\Php",
  4. ".volt" => "Phalcon\Mvc\View\Engine\Volt",
  5. ".mhtml" => "MyCustomEngine"
  6. ));

protected array _loadTemplateEngines ()

Loads registered template engines, if none is registered it will use Phalcon\Mvc\View\Engine\Php

final protected _internalRender (unknown $path, unknown $params)

Tries to render the view with every engine registered in the component

public string render (unknown $path, [unknown $params])

Renders a view

public partial (unknown $partialPath, [unknown $params])

Renders a partial view

  1. <?php
  2. //Show a partial inside another view
  3. $this->partial('shared/footer');
  1. <?php
  2. //Show a partial inside another view with parameters
  3. $this->partial('shared/footer', array('content' => $html));

public Phalcon\Mvc\View\Simple setCacheOptions (unknown $options)

Sets the cache options

public array getCacheOptions ()

Returns the cache options

protected Phalcon\Cache\BackendInterface _createCache ()

Create a Phalcon\Cache based on the internal cache options

public Phalcon\Cache\BackendInterface getCache ()

Returns the cache instance used to cache

public Phalcon\Mvc\View\Simple cache ([unknown $options])

Cache the actual view render to certain level

  1. <?php
  2. $this->view->cache(array('key' => 'my-key', 'lifetime' => 86400));

public Phalcon\Mvc\View\Simple setParamToView (string $key, mixed $value)

Adds parameters to views (alias of setVar)

  1. <?php
  2. $this->view->setParamToView('products', $products);

public Phalcon\Mvc\View\Simple setVars (unknown $params, [unknown $merge])

Set all the render params

  1. <?php
  2. $this->view->setVars(array('products' => $products));

public Phalcon\Mvc\View\Simple setVar (unknown $key, unknown $value)

Set a single view parameter

  1. <?php
  2. $this->view->setVar('products', $products);

public mixed getVar (unknown $key)

Returns a parameter previously set in the view

public array getParamsToView ()

Returns parameters to views

public Phalcon\Mvc\View\Simple setContent (unknown $content)

Externally sets the view content

  1. <?php
  2. $this->view->setContent("<h1>hello</h1>");

public string getContent ()

Returns cached ouput from another view stage

public string getActiveRenderPath ()

Returns the path of the view that is currently rendered

public __set (unknown $key, unknown $value)

Magic method to pass variables to the views

  1. <?php
  2. $this->view->products = $products;

public mixed __get (unknown $key)

Magic method to retrieve a variable passed to the view

  1. <?php
  2. echo $this->view->products;

public setDI (unknown $dependencyInjector) inherited from Phalcon\Di\Injectable

Sets the dependency injector

public Phalcon\DiInterface getDI () inherited from Phalcon\Di\Injectable

Returns the internal dependency injector

public setEventsManager (unknown $eventsManager) inherited from Phalcon\Di\Injectable

Sets the event manager

public Phalcon\Events\ManagerInterface getEventsManager () inherited from Phalcon\Di\Injectable

Returns the internal event manager