I'm developing a custom template and am interested in creating a round user icon with the first letter of their name (Google Docs style). In order to do that, I have to generate the first letter with PHP. I've gotten it to work nicely, but only if this function is in inc/template.php
:
function tpl_usericon() {
global $lang;
global $INPUT;
if($INPUT->server->str('REMOTE_USER')) {
$tdusername = userlink();
$tduserletter = $tdusername[0];
print $tduserletter;
return true;
}
return false;
}
However, this is obviously not an ideal location because it is right in the dokuwiki core. The function stops working when I try to move it to lib/tpl/<mytemplate>/tpl_functions.php
. I'm an extreme novice with PHP, so any tips on how to fix this are appreciated.
(If you're curious, here's the code I use to display it on the page🙂
<?php
if (!empty($_SERVER['REMOTE_USER'])) {
tpl_usericon();
}
else {
echo '<span class="input-icon mu mu-user"></span>';
}
?>