diff --git a/developer_manual/templates.rst b/developer_manual/templates.rst index 00d496767..0db62dc6e 100644 --- a/developer_manual/templates.rst +++ b/developer_manual/templates.rst @@ -17,6 +17,14 @@ Template class :param string $renderas: If $renderas is set, OC_Template will try to produce a full page in the according layout. For now, renderas can be set to "guest", "user" or "admin" :returns: OC_Template object + **Example:** + + .. code-block:: php + + + .. php:method:: addHeader($tag, $attributes[, $text='']) @@ -26,6 +34,14 @@ Template class Add a custom element to the html + **Example:** + + .. code-block:: php + + addHeader('title', array(), 'My new Page'); + ?> .. php:method:: append($key, $value) @@ -35,6 +51,18 @@ Template class This function assigns a variable in an array context. If the key already exists, the value will be appended. It can be accessed via $_[$key][$position] in the template. + **Example:** + + .. code-block:: php + + assign('customers', $customers); + $mainTemplate->append('customers', 'hanna'); + ?> + .. php:method:: assign($key, $value[, $sanitizeHTML=true]) @@ -45,11 +73,30 @@ Template class This function assigns a variable. It can be accessed via $_[$key] in the template. If the key existed before, it will be overwritten + **Example:** + + .. code-block:: php + + assign('customers', $customers); + ?> + .. php:method:: detectFormfactor() :returns: The mode of the client as a string. **default** -> the normal desktop browser interface, **mobile** -> interface for smartphones, **tablet** -> interface for tablets, **standalone** -> the default interface but without header, footer and sidebar, just the application. Useful to use just a specific app on the desktop in a standalone window. + **Example:** + + .. code-block:: php + + detectFormfactor(); + ?> .. php:method:: fetchPage() @@ -58,12 +105,30 @@ Template class This function proceeds the template and but prints no output. + **Example:** + + .. code-block:: php + + + .. php:method:: getFormFactorExtension() :returns: Returns the formfactor extension for current formfactor (like .mobile or .tablet) + **Example:** + + .. code-block:: php + + detectFormfactorExtension(); + ?> + + .. php:method:: inc($file[, $additionalparams]) :param string $file: the name of the template @@ -72,6 +137,14 @@ Template class Includes another template. use inc('template'); ?> to do this. + **Example:** + + .. code-block:: php + +
+ inc('nav.inc', array('active' => 'nav_entry_1')); ?> +
+ .. php:method:: printPage() @@ -79,6 +152,15 @@ Template class This function proceeds the template and prints its output. + **Example:** + + .. code-block:: php + + assign('test', array("test", "test2")); + $mainTemplate->printPage(); + ?> .. php:method:: printAdminPage($application, $name[, $parameters]) @@ -87,6 +169,14 @@ Template class :param array $parameters: Parameters for the template :returns: bool + **Example:** + + .. code-block:: php + + + Shortcut to print a simple page for admin @@ -97,6 +187,14 @@ Template class :param array $parameters: Parameters for the template :returns: bool + **Example:** + + .. code-block:: php + + + Shortcut to print a simple page for guests @@ -109,6 +207,14 @@ Template class Shortcut to print a simple page for users + **Example:** + + .. code-block:: php + + + Template syntax ---------------