Skip to content
Snippets Groups Projects
Commit 4902c95b authored by Kathrin Osswald's avatar Kathrin Osswald
Browse files

Setting to place the link to the homepage always on top of the nav drawer.

parent f96ba837
Branches
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ Changes ...@@ -6,6 +6,7 @@ Changes
### Unreleased ### Unreleased
* 2017-07-14 - Setting to place the link to the homepage always on top of the nav drawer.
* 2017-07-14 - Minor change to use bootstrap z-index variable for the maintenance warning. * 2017-07-14 - Minor change to use bootstrap z-index variable for the maintenance warning.
* 2017-07-12 - Made changes from 2017-22-05 'Adding additional classes to list group items' undone because it won't be integrated into Moodle core. * 2017-07-12 - Made changes from 2017-22-05 'Adding additional classes to list group items' undone because it won't be integrated into Moodle core.
* 2017-07-06 - Improved "Back to top": Javascript and icon. * 2017-07-06 - Improved "Back to top": Javascript and icon.
......
...@@ -157,6 +157,12 @@ With this setting you can change the height in pixels for your uploaded badges. ...@@ -157,6 +157,12 @@ With this setting you can change the height in pixels for your uploaded badges.
Whatever you add to this textarea will be displayed beneath the footer on every page that renders the theme standard footer (for layouts "columns2", "login" and "maintenance"). Content in this area could be for example the copyright, the terms of use and the name of your organisation. Whatever you add to this textarea will be displayed beneath the footer on every page that renders the theme standard footer (for layouts "columns2", "login" and "maintenance"). Content in this area could be for example the copyright, the terms of use and the name of your organisation.
#### Nav drawer menu
##### Default homepage on top
By checking this setting the default homepage link (Dashboard or Site home) will always be located at the top of the nav drawer. By default, this is already the case on every Moodle page except for course pages. There, the current course and its contents are placed on top. This might break user's expectations for the placement of the default homepage link.
### 6. Tab "Design Settings" ### 6. Tab "Design Settings"
......
...@@ -115,6 +115,16 @@ $string['footnoteheadingsetting'] = 'Footnote'; ...@@ -115,6 +115,16 @@ $string['footnoteheadingsetting'] = 'Footnote';
$string['footnoteheadingsetting_desc'] = 'The following setting allows to add an additional region for displaying a footnote.'; $string['footnoteheadingsetting_desc'] = 'The following setting allows to add an additional region for displaying a footnote.';
$string['footnotesetting'] = 'Footnote'; $string['footnotesetting'] = 'Footnote';
$string['footnotesetting_desc'] = 'Whatever you add to this textarea will be displayed at the end of the footer on every page that renders the theme standard footer (for the layouts "columns2" and "login"). Content in this area could be for example the copyright, the terms of use and the name of your organisation. <br/> If you want to remove the footnote again, just empty the text area.'; $string['footnotesetting_desc'] = 'Whatever you add to this textarea will be displayed at the end of the footer on every page that renders the theme standard footer (for the layouts "columns2" and "login"). Content in this area could be for example the copyright, the terms of use and the name of your organisation. <br/> If you want to remove the footnote again, just empty the text area.';
// ...Nav drawer menu.
$string['navdrawerheadingsetting'] = 'Nav drawer menu';
$string['dashboardontopsetting'] = 'Dashboard menu item on top';
$string['dashboardontopsetting_desc'] = 'By checking this setting the Dashboard menu item will always be located at the top of the nav drawer. By default, this is already the case on every Moodle page except for course pages. There, the current course and its contents are placed on top. This might break user\'s expectations for the placement of the default homepage link.';
$string['sitehomeontopsetting'] = 'Site home menu item on top';
$string['sitehomeontopsetting_desc'] = 'By checking this setting the Site home menu item will always be located at the top of the nav drawer. By default, this is already the case on every Moodle page except for course pages. There, the current course and its contents are placed on top. This might break user\'s expectations for the placement of the default homepage link.';
$string['userdefinedontopsetting'] = 'User defined homepage on top';
$string['userdefinedontopsetting_desc'] = 'By checking this setting the Dashboard or Site home menu item (depends on the user\'s preferences) will always be located at the top of the nav drawer. By default, this is already the case on every Moodle page except for course pages. There, the current course and its contents are placed on top. This might break user\'s expectations for the placement of the default homepage link.';
$string['defaulthomepageontopsetting'] = 'Default homepage on top';
$string['defaulthomepageontopsetting_desc'] = 'By checking this setting the default homepage link (Dashboard or Site home) will always be located at the top of the nav drawer. By default, this is already the case on every Moodle page except for course pages. There, the current course and its contents are placed on top. This might break user\'s expectations for the placement of the default homepage link.';
// Design settings. // Design settings.
$string['designsettings'] = 'Design Settings'; $string['designsettings'] = 'Design Settings';
...@@ -138,4 +148,3 @@ $string['blockiconsetting_desc_code'] = '.block_people .card-block .card-title:: ...@@ -138,4 +148,3 @@ $string['blockiconsetting_desc_code'] = '.block_people .card-block .card-title::
$string['navbardesignheadingsetting'] = 'Navbar'; $string['navbardesignheadingsetting'] = 'Navbar';
$string['darknavbarsetting'] = 'Dark navbar'; $string['darknavbarsetting'] = 'Dark navbar';
$string['darknavbarsetting_desc'] = 'By checking this setting you can invert the default light navbar to a dark one with white links.'; $string['darknavbarsetting_desc'] = 'By checking this setting you can invert the default light navbar to a dark one with white links.';
...@@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die(); ...@@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die();
user_preference_allow_ajax_update('drawer-open-nav', PARAM_ALPHA); user_preference_allow_ajax_update('drawer-open-nav', PARAM_ALPHA);
require_once($CFG->libdir . '/behat/lib.php'); require_once($CFG->libdir . '/behat/lib.php');
require_once($CFG->dirroot . '/theme/boost_campus/locallib.php');
if (isloggedin()) { if (isloggedin()) {
$navdraweropen = (get_user_preferences('drawer-open-nav', 'true') == 'true'); $navdraweropen = (get_user_preferences('drawer-open-nav', 'true') == 'true');
...@@ -66,8 +67,9 @@ $templatecontext = [ ...@@ -66,8 +67,9 @@ $templatecontext = [
'catchshortcuts' => json_encode($catchshortcuts) 'catchshortcuts' => json_encode($catchshortcuts)
]; ];
$templatecontext['flatnavigation'] = $PAGE->flatnav;
// MODIDFICATION START. // MODIDFICATION START.
// Use the returned value from theme_boost_campus_get_modified_flatnav_defaulthomepageontop as the template context.
$templatecontext['flatnavigation'] = theme_boost_campus_process_flatnav($PAGE->flatnav);
// Render colums2.mustache from boost_campus. // Render colums2.mustache from boost_campus.
echo $OUTPUT->render_from_template('theme_boost_campus/columns2', $templatecontext); echo $OUTPUT->render_from_template('theme_boost_campus/columns2', $templatecontext);
// MODIFICATION END. // MODIFICATION END.
......
...@@ -94,7 +94,7 @@ function theme_boost_campus_get_pre_scss($theme) { ...@@ -94,7 +94,7 @@ function theme_boost_campus_get_pre_scss($theme) {
'branddangercolor' => ['brand-danger'], 'branddangercolor' => ['brand-danger'],
'darknavbar' => ['darknavbar'], 'darknavbar' => ['darknavbar'],
'footerblocks' => ['footerblocks'], 'footerblocks' => ['footerblocks'],
'badgeareaitemsmaxheight' => ['badgeareaitemsmaxheight'], 'badgeareaitemsmaxheight' => ['badgeareaitemsmaxheight']
/* MODIFICATION END */ /* MODIFICATION END */
]; ];
......
...@@ -162,3 +162,73 @@ function theme_boost_campus_get_badgeareacontent() { ...@@ -162,3 +162,73 @@ function theme_boost_campus_get_badgeareacontent() {
} }
} }
} }
/**
* Returns a modified flat_navigation object.
*
* @param flat_navigation $flatnav The flat navigation object.
* @return flat_navigation.
*/
function theme_boost_campus_process_flatnav(flat_navigation $flatnav) {
global $USER;
// If the setting defaulthomepageontop is enabled.
if (get_config('theme_boost_campus', 'defaulthomepageontop') == 'yes') {
// Only proceed processing if we are in a course context.
if ($flatnav->find('coursehome', global_navigation::TYPE_CUSTOM) != false) {
// If the site home is set as the deafult homepage by the admin.
if (get_config('core', 'defaulthomepage') == HOMEPAGE_SITE) {
// Return the modified flat_navigtation.
$flatnavreturn = theme_boost_campus_set_node_on_top($flatnav, 'home');
} else if (get_config('core', 'defaulthomepage') == HOMEPAGE_MY) { // If the dashboard is set as the default homepage
// by the admin.
// Return the modified flat_navigtation.
$flatnavreturn = theme_boost_campus_set_node_on_top($flatnav, 'myhome');
} else if (get_config('core', 'defaulthomepage') == HOMEPAGE_USER) { // If the admin defined that the user can set
// the default homepage for himself.
// Site home.
if (get_user_preferences('user_home_page_preference', $USER) == 0) {
// Return the modified flat_navigtation.
$flatnavreturn = theme_boost_campus_set_node_on_top($flatnav, 'home');
} else if (get_user_preferences('user_home_page_preference', $USER) == 1 || // Dashboard.
get_user_preferences('user_home_page_preference', $USER) == false) { // If no user preference is set,
// use the default value of core setting default homepage (Dashboard).
// Return the modified flat_navigtation.
$flatnavreturn = theme_boost_campus_set_node_on_top($flatnav, 'myhome');
} else { // Should not happen.
// Return the passed flat navigation without changes.
$flatnavreturn = $flatnav;
}
} else { // Should not happen.
// Return the passed flat navigation without changes.
$flatnavreturn = $flatnav;
}
} else { // Not in course context.
// Return the passed flat navigation without changes.
$flatnavreturn = $flatnav;
}
} else { // Defaulthomepageontop not enabled.
// Return the passed flat navigation without changes.
$flatnavreturn = $flatnav;
}
return $flatnavreturn;
}
/**
* Modifies the flat_navigation to add the node on top.
*
* @param flat_navigation $flatnav The flat navigation object.
* @param string $nodename The name of the node that is to modify.
* @return flat_navigation.
*/
function theme_boost_campus_set_node_on_top(flat_navigation $flatnav, $nodename) {
$pageflatnav = $flatnav->find($nodename, global_navigation::TYPE_SYSTEM);
// Add the showdivider to the coursehome node as this is the next one and this will add a margin top to it.
$flatnav->find('coursehome', global_navigation::TYPE_CUSTOM)->set_showdivider(true);
// Remove the site home navigation node that it does not appear twice in the menu.
$flatnav->remove($nodename);
// Add the saved site home node as the before node of the course home node.
$flatnav->add($pageflatnav, 'coursehome');
// Return the modified changes.
return $flatnav;
}
...@@ -213,6 +213,7 @@ body.loginbackgroundimage { ...@@ -213,6 +213,7 @@ body.loginbackgroundimage {
a.list-group-item[href*="course/view.php?id="] { a.list-group-item[href*="course/view.php?id="] {
@include navdrawer-node-separator(child); @include navdrawer-node-separator(child);
} }
a.list-group-item[href*="course/view.php?id="]:last-child { a.list-group-item[href*="course/view.php?id="]:last-child {
border-bottom: none; border-bottom: none;
} }
......
...@@ -352,6 +352,42 @@ if ($ADMIN->fulltree) { ...@@ -352,6 +352,42 @@ if ($ADMIN->fulltree) {
$setting->set_updatedcallback('theme_reset_all_caches'); $setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting); $page->add($setting);
// Settings title to group navdrawer related settings together with a common heading. We don't want a description here.
$setting = new admin_setting_heading('theme_boost_campus/navdrawerheading',
get_string('navdrawerheadingsetting', 'theme_boost_campus', null, true), null);
$page->add($setting);
// Create default homepage on top control widget (switch label and description depending on what will really happen on the site).
if (get_config('core', 'defaulthomepage') == HOMEPAGE_SITE) {
$page->add(new admin_setting_configcheckbox('theme_boost_campus/defaulthomepageontop',
get_string('sitehomeontopsetting', 'theme_boost_campus', null, true),
get_string('sitehomeontopsetting_desc', 'theme_boost_campus', null, true), 'no', 'yes', 'no'));
// Overriding default values yes = 1 and no = 0 because of the use of empty() in theme_boost_campus_get_pre_scss()
// (lib.php). Default 0 value would not write the variable to scss that could cause the scss to crash if used in
// that file. See MDL-58376.
} else if (get_config('core', 'defaulthomepage') == HOMEPAGE_MY) {
$page->add(new admin_setting_configcheckbox('theme_boost_campus/defaulthomepageontop',
get_string('dashboardontopsetting', 'theme_boost_campus', null, true),
get_string('dashboardontopsetting_desc', 'theme_boost_campus', null, true), 'no', 'yes', 'no'));
// Overriding default values yes = 1 and no = 0 because of the use of empty() in theme_boost_campus_get_pre_scss()
// (lib.php). Default 0 value would not write the variable to scss that could cause the scss to crash if used in
// that file. See MDL-58376.
} else if (get_config('core', 'defaulthomepage') == HOMEPAGE_USER) {
$page->add(new admin_setting_configcheckbox('theme_boost_campus/defaulthomepageontop',
get_string('userdefinedontopsetting', 'theme_boost_campus', null, true),
get_string('userdefinedontopsetting_desc', 'theme_boost_campus', null, true), 'no', 'yes', 'no'));
// Overriding default values yes = 1 and no = 0 because of the use of empty() in theme_boost_campus_get_pre_scss()
// (lib.php). Default 0 value would not write the variable to scss that could cause the scss to crash if used in
// that file. See MDL-58376.
} else { // This should not happen.
$page->add(new admin_setting_configcheckbox('theme_boost_campus/defaulthomepageontop',
get_string('defaulthomepageontopsetting', 'theme_boost_campus', null, true),
get_string('defaulthomepageontopsetting_desc', 'theme_boost_campus', null, true), 'no', 'yes', 'no'));
// Overriding default values yes = 1 and no = 0 because of the use of empty() in theme_boost_campus_get_pre_scss()
// (lib.php). Default 0 value would not write the variable to scss that could cause the scss to crash if used in
// that file. See MDL-58376.
}
// Add tab to settings page. // Add tab to settings page.
$settings->add($page); $settings->add($page);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment