From 7a02f020c389f6cc56bb54d25d9106c0b4d2641e Mon Sep 17 00:00:00 2001 From: zpottie Date: Thu, 2 May 2019 17:17:22 +1200 Subject: [PATCH] MDL-58315 core: Add support for custom block classes --- blocks/moodleblock.class.php | 4 ++-- lib/outputrenderers.php | 1 + lib/templates/block.mustache | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/blocks/moodleblock.class.php b/blocks/moodleblock.class.php index 9c58f63d3d4..c912d51ae23 100644 --- a/blocks/moodleblock.class.php +++ b/blocks/moodleblock.class.php @@ -429,13 +429,13 @@ class block_base { function html_attributes() { $attributes = array( 'id' => 'inst' . $this->instance->id, - 'class' => 'block_' . $this->name(). ' block', + 'class' => 'block_' . $this->name() . ' block', 'role' => $this->get_aria_role() ); if ($this->hide_header()) { $attributes['class'] .= ' no-header'; } - if ($this->instance_can_be_docked() && get_user_preferences('docked_block_instance_'.$this->instance->id, 0)) { + if ($this->instance_can_be_docked() && get_user_preferences('docked_block_instance_' . $this->instance->id, 0)) { $attributes['class'] .= ' dock_on_load'; } return $attributes; diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 437a1f3d814..07c63eaf1d3 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -1717,6 +1717,7 @@ class core_renderer extends renderer_base { $context->showskiplink = !empty($context->skiptitle); $context->arialabel = $bc->arialabel; $context->ariarole = !empty($bc->attributes['role']) ? $bc->attributes['role'] : 'complementary'; + $context->class = $bc->attributes['class']; $context->type = $bc->attributes['data-block']; $context->title = $bc->title; $context->content = $bc->content; diff --git a/lib/templates/block.mustache b/lib/templates/block.mustache index 09560bc8915..a08aeed7166 100644 --- a/lib/templates/block.mustache +++ b/lib/templates/block.mustache @@ -4,6 +4,7 @@ Example context (json): { "id": "block0", + "class": "block block_html", "showskiplink": true, "type": "html", "ariarole": "complementary", @@ -20,7 +21,7 @@ {{! Start Block Container }}