Moved section public html templates

Signed-off-by: Christian Wolf <github@christianwolf.email>
This commit is contained in:
Christian Wolf
2025-02-28 13:04:51 +01:00
parent 2f1bc359c4
commit 9e95840608

View File

@@ -387,6 +387,43 @@ A :doc:`template <front-end/templates>` can be rendered by returning a TemplateR
Public page templates
^^^^^^^^^^^^^^^^^^^^^
For public pages, that are rendered to users who are not logged in to the
Nextcloud instance, a ``OCP\\AppFramework\\Http\\Template\\PublicTemplateResponse`` should be used, to load the
correct base template. It also allows adding an optional set of actions that
will be shown in the top right corner of the public page.
.. code-block:: php
<?php
namespace OCA\MyApp\Controller;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Template\SimpleMenuAction;
use OCP\AppFramework\Http\Template\PublicTemplateResponse;
class PageController extends Controller {
public function index(): PublicTemplateResponse {
$template = new PublicTemplateResponse($this->appName, 'main', []);
$template->setHeaderTitle('Public page');
$template->setHeaderDetails('some details');
$template->setHeaderActions([
new SimpleMenuAction('download', 'Label 1', 'icon-css-class1', 'link-url', 0),
new SimpleMenuAction('share', 'Label 2', 'icon-css-class2', 'link-url', 10),
]);
return $template;
}
}
The header title and subtitle will be rendered in the header, next to the logo.
The action with the highest priority (lowest number) will be used as the
primary action, others will shown in the popover menu on demand.
A ``OCP\\AppFramework\\Http\\Template\\SimpleMenuAction`` will be a link with an icon added to the menu. App
developers can implement their own types of menu renderings by adding a custom
class implementing the ``OCP\\AppFramework\\Http\\Template\\IMenuAction`` interface.
Data-based responses
--------------------
@@ -566,48 +603,6 @@ Because returning values works fine in case of a success but not in case of fail
}
Public page templates
^^^^^^^^^^^^^^^^^^^^^
For public pages, that are rendered to users who are not logged in to the
Nextcloud instance, a ``OCP\\AppFramework\\Http\\Template\\PublicTemplateResponse`` should be used, to load the
correct base template. It also allows adding an optional set of actions that
will be shown in the top right corner of the public page.
.. code-block:: php
<?php
namespace OCA\MyApp\Controller;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Template\SimpleMenuAction;
use OCP\AppFramework\Http\Template\PublicTemplateResponse;
class PageController extends Controller {
public function index(): PublicTemplateResponse {
$template = new PublicTemplateResponse($this->appName, 'main', []);
$template->setHeaderTitle('Public page');
$template->setHeaderDetails('some details');
$template->setHeaderActions([
new SimpleMenuAction('download', 'Label 1', 'icon-css-class1', 'link-url', 0),
new SimpleMenuAction('share', 'Label 2', 'icon-css-class2', 'link-url', 10),
]);
return $template;
}
}
The header title and subtitle will be rendered in the header, next to the logo.
The action with the highest priority (lowest number) will be used as the
primary action, others will shown in the popover menu on demand.
A ``OCP\\AppFramework\\Http\\Template\\SimpleMenuAction`` will be a link with an icon added to the menu. App
developers can implement their own types of menu renderings by adding a custom
class implementing the ``OCP\\AppFramework\\Http\\Template\\IMenuAction`` interface.
Redirects
^^^^^^^^^