diff options
| author | David Siegfried <david.siegfried@uni-vechta.de> | 2022-05-30 12:48:16 +0000 |
|---|---|---|
| committer | noackorama <noackorama@gmail.com> | 2022-06-01 16:47:18 +0200 |
| commit | cec0fa917e2d28d462aeeed1c7c300543fbe925e (patch) | |
| tree | 2c9893c273db3a3ba429d0b336ed69bf76e20116 | |
| parent | 15779b85a6a676be8bcc09f49177fa7b4e66724d (diff) | |
render template widget correctly, fixes #1115, re #1102
Merge request studip/studip!666
| -rw-r--r-- | lib/classes/sidebar/ResourceTreeWidget.class.php | 7 | ||||
| -rw-r--r-- | lib/classes/sidebar/SidebarWidget.php | 23 |
2 files changed, 22 insertions, 8 deletions
diff --git a/lib/classes/sidebar/ResourceTreeWidget.class.php b/lib/classes/sidebar/ResourceTreeWidget.class.php index c99192e..75befd4 100644 --- a/lib/classes/sidebar/ResourceTreeWidget.class.php +++ b/lib/classes/sidebar/ResourceTreeWidget.class.php @@ -116,12 +116,7 @@ class ResourceTreeWidget extends SidebarWidget $variables['max_open_depth'] = 0; $variables['layout_css_classes'] = $this->layout_css_classes; - $template = $GLOBALS['template_factory']->open( - $this->template - ); - $template->set_attributes($variables); - $template->set_layout('sidebar/widget-layout'); - return $template->render(); + return parent::render($variables); } public function setCurrentResource(Resource $resource) diff --git a/lib/classes/sidebar/SidebarWidget.php b/lib/classes/sidebar/SidebarWidget.php index 0e4cc5f..7075b8a 100644 --- a/lib/classes/sidebar/SidebarWidget.php +++ b/lib/classes/sidebar/SidebarWidget.php @@ -11,13 +11,33 @@ class SidebarWidget extends Widget { protected $additional_attributes = []; - public function __construct() { $this->layout = 'sidebar/widget-layout.php'; } /** + * Sets the ID of the HTML element that represents the widget. + * + * @param $id The element-ID to be used for the widget. + * + */ + public function setId(string $id) + { + $this->id = $id; + } + + /** + * Returns the ID of this widget, if it is set. + * + * @return string The ID of the widget or an empty string, if it is not set. + */ + public function getId() : string + { + return $this->id ?? ''; + } + + /** * Sets the title of the widget. * * @param String $title The title of the widget @@ -77,7 +97,6 @@ class SidebarWidget extends Widget unset($this->additional_attributes[$key]); } - /** * Renders the widget. * The widget will only be rendered if it contains at least one element. |
