TemplateResponse

class OCP\AppFramework\Http\TemplateResponse
Response for a normal template
Source:lib/public/AppFramework/Http/TemplateResponse.php#41
Parent:OCP\AppFramework\Http\Response

Constants

RENDER_AS_GUEST = guest
Source:lib/public/AppFramework/Http/TemplateResponse.php#45
Since:20.0.0
RENDER_AS_BLANK =
Source:lib/public/AppFramework/Http/TemplateResponse.php#49
Since:20.0.0
RENDER_AS_BASE = base
Source:lib/public/AppFramework/Http/TemplateResponse.php#53
Since:20.0.0
RENDER_AS_USER = user
Source:lib/public/AppFramework/Http/TemplateResponse.php#57
Since:20.0.0
RENDER_AS_ERROR = error
Source:lib/public/AppFramework/Http/TemplateResponse.php#61
Since:20.0.0
RENDER_AS_PUBLIC = public
Source:lib/public/AppFramework/Http/TemplateResponse.php#65
Since:20.0.0
EVENT_LOAD_ADDITIONAL_SCRIPTS = self::class . ::loadAdditionalScripts
Source:lib/public/AppFramework/Http/TemplateResponse.php#70
Deprecated:20.0.0 use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent
EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN = self::class . ::loadAdditionalScriptsLoggedIn
Source:lib/public/AppFramework/Http/TemplateResponse.php#74
Deprecated:20.0.0 use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent

Properties

protected static property OCP\AppFramework\Http\TemplateResponse::$templateName
name of the template
Source:lib/public/AppFramework/Http/TemplateResponse.php#80
Type:string
protected static property OCP\AppFramework\Http\TemplateResponse::$params
parameters
Source:lib/public/AppFramework/Http/TemplateResponse.php#86
Type:array
protected static property OCP\AppFramework\Http\TemplateResponse::$renderAs
rendering type (admin, user, blank)
Source:lib/public/AppFramework/Http/TemplateResponse.php#92
Type:string
protected static property OCP\AppFramework\Http\TemplateResponse::$appName
app name
Source:lib/public/AppFramework/Http/TemplateResponse.php#98
Type:string

Methods

public OCP\AppFramework\Http\TemplateResponse::__construct($appName, $templateName, $params=[], $renderAs=self::RENDER_AS_USER)
constructor of TemplateResponse
Source:

lib/public/AppFramework/Http/TemplateResponse.php#109

Parameters:
  • $appName (string) the name of the app to load the template from
  • $templateName (string) the name of the template
  • $params (array) an array of parameters which should be passed to the

template * $renderAs (string) how the page should be rendered, defaults to user

Since:

6.0.0 - parameters $params and $renderAs were added in 7.0.0

public OCP\AppFramework\Http\TemplateResponse::setParams($params)
Sets template parameters
Source:

lib/public/AppFramework/Http/TemplateResponse.php#130

Parameters:
  • $params (array) an array with key => value structure which sets template

variables

Returns:

\OCP\AppFramework\Http\TemplateResponse Reference to this object

Since:

6.0.0 - return value was added in 7.0.0

public OCP\AppFramework\Http\TemplateResponse::getParams()
Used for accessing the set parameters
Source:lib/public/AppFramework/Http/TemplateResponse.php#142
Returns:array the params
Since:6.0.0
public OCP\AppFramework\Http\TemplateResponse::getTemplateName()
Used for accessing the name of the set template
Source:lib/public/AppFramework/Http/TemplateResponse.php#152
Returns:string the name of the used template
Since:6.0.0
public OCP\AppFramework\Http\TemplateResponse::renderAs($renderAs)
Sets the template page
Source:

lib/public/AppFramework/Http/TemplateResponse.php#166

Parameters:
  • $renderAs (string) admin, user or blank. Admin also prints the admin

settings header and footer, user renders the normal normal page including footer and header and blank just renders the plain template

Returns:

\OCP\AppFramework\Http\TemplateResponse Reference to this object

Since:

6.0.0 - return value was added in 7.0.0

public OCP\AppFramework\Http\TemplateResponse::getRenderAs()
Returns the set renderAs
Source:lib/public/AppFramework/Http/TemplateResponse.php#178
Returns:string the renderAs value
Since:6.0.0
public OCP\AppFramework\Http\TemplateResponse::render()
Returns the rendered html
Source:lib/public/AppFramework/Http/TemplateResponse.php#188
Returns:string the rendered html
Since:6.0.0