diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 88bf930e180..60cd2dd934a 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -4261,6 +4261,14 @@ EOD; public function full_header() { global $PAGE; + if ($PAGE->include_region_main_settings_in_header_actions()) { + $PAGE->add_header_action(html_writer::div( + $this->region_main_settings_menu(), + 'd-print-none', + ['id' => 'region-main-settings-menu'] + )); + } + $header = new stdClass(); $header->settingsmenu = $this->context_header_settings_menu(); $header->contextheader = $this->context_header(); @@ -4268,6 +4276,7 @@ EOD; $header->navbar = $this->navbar(); $header->pageheadingbutton = $this->page_heading_button(); $header->courseheader = $this->course_header(); + $header->headeractions = $PAGE->get_header_actions(); return $this->render_from_template('core/full_header', $header); } diff --git a/lib/pagelib.php b/lib/pagelib.php index 97d185d8851..1447623977d 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -353,6 +353,16 @@ class moodle_page { */ protected $_forcesettingsmenu = false; + /** + * @var array Array of header actions HTML to add to the page header actions menu. + */ + protected $_headeractions = []; + + /** + * @var bool Should the region main settings menu be rendered in the header. + */ + protected $_regionmainsettingsinheader = false; + /** * Force the settings menu to be displayed on this page. This will only force the * settings menu on an activity / resource page that is being displayed on a theme that @@ -2032,4 +2042,42 @@ class moodle_page { // Finally add the report to the navigation tree. $reportnode->add($nodeinfo['name'], $nodeinfo['url'], navigation_node::TYPE_COURSE); } + + /** + * Add some HTML to the list of actions to render in the header actions menu. + * + * @param string $html The HTML to add. + */ + public function add_header_action(string $html) : void { + $this->_headeractions[] = $html; + } + + /** + * Get the list of HTML for actions to render in the header actions menu. + * + * @return string[] + */ + public function get_header_actions() : array { + return $this->_headeractions; + } + + /** + * Set the flag to indicate if the region main settings should be rendered as an action + * in the header actions menu rather than at the top of the content. + * + * @param bool $value If the settings should be in the header. + */ + public function set_include_region_main_settings_in_header_actions(bool $value) : void { + $this->_regionmainsettingsinheader = $value; + } + + /** + * Check if the region main settings should be rendered as an action in the header actions + * menu rather than at the top of the content. + * + * @return bool + */ + public function include_region_main_settings_in_header_actions() : bool { + return $this->_regionmainsettingsinheader; + } } diff --git a/lib/templates/full_header.mustache b/lib/templates/full_header.mustache index 1954bb2984e..c1feb3ef7c7 100644 --- a/lib/templates/full_header.mustache +++ b/lib/templates/full_header.mustache @@ -32,7 +32,7 @@
-
+
{{#contextheader}}
{{{contextheader}}} @@ -44,6 +44,11 @@ {{{settingsmenu}}}
{{/settingsmenu}} +
+ {{#headeractions}} +
{{{.}}}
+ {{/headeractions}} +
{{#hasnavbar}} diff --git a/mod/forum/view.php b/mod/forum/view.php index f07a18a4d7e..30d640a2084 100644 --- a/mod/forum/view.php +++ b/mod/forum/view.php @@ -89,6 +89,7 @@ $PAGE->set_title($forum->get_name()); $PAGE->add_body_class('forumtype-' . $forum->get_type() . ' reset-style'); $PAGE->set_heading($course->fullname); $PAGE->set_button(forum_search_form($course, $search)); +$PAGE->set_include_region_main_settings_in_header_actions(true); if ($istypesingle && $displaymode == FORUM_MODE_MODERN) { $PAGE->add_body_class('modern-display-mode reset-style'); diff --git a/theme/boost/layout/columns2.php b/theme/boost/layout/columns2.php index b44726f91bf..384158d94e5 100644 --- a/theme/boost/layout/columns2.php +++ b/theme/boost/layout/columns2.php @@ -39,7 +39,9 @@ if ($navdraweropen) { $bodyattributes = $OUTPUT->body_attributes($extraclasses); $blockshtml = $OUTPUT->blocks('side-pre'); $hasblocks = strpos($blockshtml, 'data-block=') !== false; -$regionmainsettingsmenu = $OUTPUT->region_main_settings_menu(); +$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions(); +// If the settings menu will be included in the header then don't add it here. +$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false; $templatecontext = [ 'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]), 'output' => $OUTPUT, diff --git a/theme/boost/scss/moodle/blocks.scss b/theme/boost/scss/moodle/blocks.scss index 95e22b3a739..ecc5688aa02 100644 --- a/theme/boost/scss/moodle/blocks.scss +++ b/theme/boost/scss/moodle/blocks.scss @@ -69,6 +69,20 @@ $blocks-plus-gutter: $blocks-column-width + ( $grid-gutter-width / 2 ); } } +.header-action { + #region-main-settings-menu { + position: unset; + float: none; + width: auto; + + & > div { + position: unset; + right: auto; + margin: 0; + } + } +} + [data-region="blocks-column"] { @include media-breakpoint-down(lg) { width: 100%; diff --git a/theme/boost/style/moodle.css b/theme/boost/style/moodle.css index c67e146ff61..15eda335231 100644 --- a/theme/boost/style/moodle.css +++ b/theme/boost/style/moodle.css @@ -12164,6 +12164,15 @@ div.editor_atto_toolbar button .icon { If modifying make sure block-region is horizontally stacked when in full screen */ display: block; } } +.header-action #region-main-settings-menu { + position: unset; + float: none; + width: auto; } + .header-action #region-main-settings-menu > div { + position: unset; + right: auto; + margin: 0; } + @media (max-width: 1199.98px) { [data-region="blocks-column"] { width: 100%; } } diff --git a/theme/classic/style/moodle.css b/theme/classic/style/moodle.css index a5784388537..f55ba959ad1 100644 --- a/theme/classic/style/moodle.css +++ b/theme/classic/style/moodle.css @@ -12420,6 +12420,15 @@ div.editor_atto_toolbar button .icon { If modifying make sure block-region is horizontally stacked when in full screen */ display: block; } } +.header-action #region-main-settings-menu { + position: unset; + float: none; + width: auto; } + .header-action #region-main-settings-menu > div { + position: unset; + right: auto; + margin: 0; } + @media (max-width: 1199.98px) { [data-region="blocks-column"] { width: 100%; } } diff --git a/theme/classic/templates/core/full_header.mustache b/theme/classic/templates/core/full_header.mustache index e033d107c01..7b61cb0b778 100644 --- a/theme/classic/templates/core/full_header.mustache +++ b/theme/classic/templates/core/full_header.mustache @@ -31,10 +31,15 @@
-
+
{{{contextheader}}}
+
+ {{#headeractions}} +
{{{.}}}
+ {{/headeractions}} +
{{#hasnavbar}}