2 This file is part of Moodle - http://moodle.org/
4 Moodle is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 Moodle is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 @template core/user_menu
22 Context variables required for this template:
23 * unauthenticateduseruser - (Optional) Items to be displayed if an an unautheticated user is accessing the site
24 * content - The content to be displayed in the header.
26 * items - Array of user menu items used in user_action_menu_items. Required if the above not provided.
27 * metadata - Array of additional metadata to be displayed in the dropdown button.
28 * avatardata - Array of avatars to be displayed. Usually only the current user's avatar. If viewing as another user,
29 includes that user's avatar.
30 * userfullname - The name of the logged in user
31 * submenus - Array of submenus within the user menu.
32 * id - The id of the submenu.
33 * title - The title of the submenu.
34 * items - Array of the submenu items used in core/user_action_menu_submenu_items.
36 Example context (json):
38 "unauthenticateduser": {
39 "content": "You are not logged in",
40 "url": "https://yourmoodlesite/login/index.php"
45 "userfullname": "Admin User",
49 "title": "Submenu title",
55 <div class="usermenu">
56 {{#unauthenticateduser}}
57 <span class="login pl-2">
59 {{#str}} loggedinasguest, core {{/str}}
60 <div class="divider border-left h-75 align-self-center mx-2"></div>
63 <a href="{{url}}">{{#str}} login, core {{/str}}</a>
66 {{/unauthenticateduser}}
67 {{^unauthenticateduser}}
68 <div class="dropdown show">
69 <a href="#" role="button" id="user-menu-toggle" data-toggle="dropdown" aria-label="{{#str}}usermenu{{/str}}"
70 aria-haspopup="true" aria-controls="user-action-menu" class="btn dropdown-toggle">
71 <span class="userbutton">
72 {{> core/user_menu_metadata }}
75 <div id="user-action-menu" class="dropdown-menu dropdown-menu-right">
76 <div id="usermenu-carousel" class="carousel slide" data-touch="false" data-interval="false" data-keyboard="false">
77 <div class="carousel-inner">
78 <div id="carousel-item-main" class="carousel-item active" role="menu" tabindex="-1" aria-label="{{#str}}user{{/str}}">
79 {{> core/user_action_menu_items }}
82 <div id="carousel-item-{{id}}" role="menu" class="carousel-item submenu" tabindex="-1" aria-label="{{title}}">
83 <div class="d-flex flex-column h-100">
85 <button type="button" class="btn btn-icon carousel-navigation-link text-decoration-none text-body" data-carousel-target-id="carousel-item-main" aria-label="{{#str}}usermenugoback{{/str}}">
86 <span class="dir-rtl-hide">{{#pix}}i/arrow-left{{/pix}}</span>
87 <span class="dir-ltr-hide">{{#pix}}i/arrow-right{{/pix}}</span>
89 <span class="pl-2" id="carousel-item-title-{{id}}">{{title}}</span>
91 <div class="dropdown-divider"></div>
92 <div class="items h-100 overflow-auto" role="menu" aria-labelledby="carousel-item-title-{{id}}">
93 {{> core/user_action_menu_submenu_items }}
102 {{/unauthenticateduser}}
105 require(['core/usermenu'], function(UserMenu) {