Simple feature

Discussion in 'Feature Requests' started by kinai, Jan 24, 2010.

  1. kinai

    kinai Member

    Hi all,

    Is it possible to add in the top banner, the username of the current login user, near logout button.

    For example,
    • You are 'ISP Admin (user admin)'
    • You are 'Resellers1 Admin (user resell1)
    • You are 'Kinaï (user kinai)

  2. BorderAmigos

    BorderAmigos New Member

    Here's a hack that will put the user name under the logo. The page needs to be refreshed once first though so not a perfect hack.

    In /var/www/ispconfig/themes/default/templates/main.tpl.htm change line 75

    <span>hosting control panel</span>
    <span>hosting control panel</span><?php echo (!($_SESSION['s']['user']['username'] == '')) ? '<br /> user:  '.$_SESSION['s']['user']['username'] : '' ; ?>
    Add that extra bit of code anywhere you want the user name to show up. No promises that this won't break something. There might be a more direct way to get the user name as well but I just hacked around until something worked.
    Last edited: Mar 4, 2010
  3. kinai

    kinai Member

    I'm applying this hack under this line.

    <span><a href="#logout" onclick="loadContent('login/logout.php');">LOGOUT</a><!-- | <a href="#" onclick="capp('help')">Help</a> | <a href="#">Imprint</a>--></span>
    and I try to change your code like

    <?php echo (!($_SESSION['s']['user']['username'] == '')) ? "<br /> {tmpl_var name='username_txt'}: ".$_SESSION['s']['user']['username'] : '' ; ?>

    but it's not working ...
    Could you help me ...

  4. BorderAmigos

    BorderAmigos New Member

    Not sure what you're trying to do and your syntax looks messed up.

    maybe you want...

    echo "<br>";
    echo ($_SESSION['s']['user']['username'] != '') ? {tmpl_var name='username_txt'}:$_SESSION['s']['user']['username'];
  5. kinai

    kinai Member


    I'm trying to display

    Username: Admin

    under logout link.

    a better solution was to have an other field to do it :

    in en_EN: current_user_text = "Your are now connected as"
    in fr_FR: current_user_text = "Vous êtes actuellement connecté en tant que"

    your php code is not working, page is not displaying.
  6. BorderAmigos

    BorderAmigos New Member

    The first one posted works but the page needs to be refreshed. The code using the template was just trying to fix the syntax. Didn't try your code to see if it worked.
  7. mike_p

    mike_p Member

    I have just posted an alternative method that does not break the template concept of avoiding mixing PHP into your HTML.

    Edit the "public function tpl_defaults()"

    add this to the bottom of the function:
        if(isset($_SESSION['s']['user'])) {
          $this->tpl->setVar('cpuser', $_SESSION['s']['user']['username']);
    Then in your templates you can use
    <tmpl_var format="strtoupper" name="cpuser">

    for example alongside the word LOGOUT in main.tpl.htm

    Hopefully the 'bosses' will include my suggested change to in future versions! :rolleyes:
  8. ikrudolf

    ikrudolf Member

    I only get the name showed when I hit the refresh button (F5).
  9. BorderAmigos

    BorderAmigos New Member

    As stated in #2 above "The page needs to be refreshed once first though so not a perfect hack." It would be interesting to know why if someone has the time to figure it out.
  10. vogelor

    vogelor ISPConfig Developer ISPConfig Developer

    i am not "the boss" - just a developer ;-)
    But ... your code is in SVN...


Share This Page