diff --git a/developer_manual/tutorial.rst b/developer_manual/tutorial.rst index 9de1cc58e..1e9d95d96 100644 --- a/developer_manual/tutorial.rst +++ b/developer_manual/tutorial.rst @@ -738,14 +738,27 @@ Templates --------- ownCloud uses its own templating system. Templates reside in the **template/** folder. In every template file you can easily access the template functions listed in :doc:`templates` -Templates are abstracted by the TemplateResponse object. Variables can be assigned to the Template by using the **setParams()** method: +Templates are abstracted by the TemplateResponse object and used and returned inside the controller method. Variables can be assigned to the Template by using the **setParams()** method: .. code-block:: php array('this', 'is', 'your', 'father', 'speaking')) - $response = new TemplateResponse($this->api, 'main'); - $response->setParams($params); + use \OCA\AppFramework\Http\TemplateResponse as TemplateResponse + + // ... + + // in your controller + + public function index(){ + + // main is the template name. Owncloud will look for template/main.php + $response = new TemplateResponse($this->api, 'main'); + + $params = array('entries' => array('this', 'is', 'your', 'father', 'speaking') + $response->setParams($params); + + return $response; + } To access the assigned variables in the template, use the **$_[]** array. The variable will be availabe under the key that you defined (e.g. $_['key']). @@ -779,29 +792,6 @@ Templates can also include other templates by using the **$this->inc('templateNa
I am included but i can still access the parents variables!
-To access the Template files in your controller, use the TemplateResponse class: - -.. code-block:: php - - api, 'main'); - - $params = array('templateVar' => 1); - $response->setParams($params); - - return $response; - } - ?> - **For more info, see** :doc:`templates`