Table des matières
Klassplace: A Flat theme
Control syntaxes for custom menu items
General syntax form
[-{0,n}]Text|[conditions!]url
members in square brackets are optional, the first one is the “heading level”
Custom menu controlled by rights
The custom menu is a global menu whose structure is controlled by the “Custom menu items” (custommenu) setting in the general theme settings (standard settings sheet). The change consists in offering a simple syntax to control whether or not menu items are visible depending on the user's situation:
<Label>|<url> Standard case, visible to everyone
<Label>|!<url> Only visible to logged-in users
<Label>|0!<url> Only visible to users who are not logged in
<Label>|m!<url> Only visible on mobile
<Label>|0m!<url> Only visible on mobile when not logged in
<Label>|xs!<url> Only visible on reduced screen widths
<Label>|capability!<url> Only visible to those who have the capability (tested on the system context or on the current course context). In this case super-users always get through.
<Label>|capability^!<url> Only visible to those who do NOT have the capability (tested on the system context or on the current course context) and explicitly so. Super-users do not see it if they do not themselves have an explicit capability.
<Label>|user:<fieldname><op><value>!<url>
Only visible to those whose user profile field “fieldname”:
- If “op” is = : equals the value
- If “op” is ~ : contains the value
The fieldname field can take any field name of the basic user profile, or point to a Moodle custom profile field, in which case it must be composed of profile_field_ followed by the short name of the custom field.
Example:
Teacher tools|user:profile_field_enseignant=1!/local/my/index_teachers.php
Variable replacement
In addition, the menu implementation injects some typical parameters of the current environment:
- %COURSEID%: The Moodle identifier of the current course
- %WWWROOT%: The Moodle web root. This lets you use absolute URLs that do not depend on the installation.
- %USERID%: The Moodle numeric identifier of the current user.
Example
Here are a few typical implementation examples:
Example of logged-in/logged-out toggle
Logout|!/login/logout.php
Connexion|0!/login
Users who are not logged in only see the 'Login' link. Logged-in users only see the 'Logout' link.
Example of control by capability
Administration|local/adminsettings:nobody!/admin/index.php
Administration|moodle/site:config^!/local/admin/delegatedadmin.php
Only administrators who have the local/adminsettings:nobody capability, including through a super-administrator right, can see the admin/index.php menu (the standard full administration console) Users who explicitly have the moodle/site:config capability through a role assignment can reach the delegated (simplified) administration panel. Super-users (site administrators) with no other explicit role assignments do not see this menu.
Example of control by capability with parameter passing
Librairie|repository/sharedresources:view!/local/sharedresources/index.php?course=%COURSEID%
Users with the required capability (see the library) can see this link button to the home of the shared library. The numeric identifier of the current course is passed to the library as the current usage context.
Invoking image links instead of texts
Condition: the image URL is known and not restricted in terms of access rights (if the menu is accessible to users who are not logged in).
The image invocation is done in the “text” part of the link definition (i.e. the first member before the | separating the URL and the encoding of access conditions)
[Text][ img:url[size_extension]
Size extension:
By passing parameters in the URL
[?&]d=w[0-9%px]+xh[0-9%px]
Possible forms:
- ?d=w100pxxh30px
- &d=w100%xh32px
- ?d=w50%xh50%
Example:
Ministry of Justice img:https://enap36-qualif.activeprolearn.com/pluginfile.php/1/local_cms/body/1/logos.png?d=w100%xh32px
Credits
- Valéry Frémaux (valery@activeprolearn.com)- Development and tests
- Florence Labord (florence@activeprolearn.com) : Documentation and tests
Back to the user guide - Theme index - Back to the plugins index - Back to the catalogue
