Diferencia entre revisiones de «Personalizando el menú de usuario del tema»
(tidy up) |
(tidy up) |
||
Línea 33: | Línea 33: | ||
==See also== | ==See also== | ||
* MDL-50839 - Allow themes to set User menu avatar size | * MDL-50839 - Allow themes to set User menu avatar size | ||
* [ | * [https://docs.moodle.org/dev/Overriding_a_renderer Overriding a renderer] | ||
[[Categoría:Temas]] | [[Categoría:Temas]] | ||
[[en:Customising the theme user menu]] | [[en:Customising the theme user menu]] |
Revisión del 16:00 1 nov 2015
Moodle 3.0
As of 3.0, the user menu can be customised via an array of options, when it is called via user_get_user_navigation_info()
.
Initially, only the size of the user's avatar picture can be changed (from the default of 35px square), using the avatarsize
key with a new size.
user_get_user_navigation_info($user, $this->page, array('avatarsize' => 85));
Unfortunately, to change the one line that calls user_get_user_navigation_info()
, the whole of core_renderer::user_menu()
must be overridden:
In /themes/<yourtheme>/renderers.lib...
public function user_menu($user = null, $withlinks = null, $loginlogo = null) {
// Lots of code copied from lib/outputrenderers.php...
// Get some navigation opts.
$opts = user_get_user_navigation_info($user, $this->page, array('avatarsize' => 85));
$avatarclasses = "avatars";
$avatarcontents = html_writer::span($opts->metadata['useravatar'], 'avatar current');
$usertextcontents = $opts->metadata['userfullname'];
// Lots more code copied from lib/outputrenderers.php...
}
NB: The image size in the browser may be enforced via CSS, with the pixel size of the image rounded up to one of a few hard-coded sizes - see MDL-50420.
See also
- MDL-50839 - Allow themes to set User menu avatar size
- Overriding a renderer