How to reference user_name variable?

I want to add a small icon to the left of the documentation icon at the top right, that will have a mouse-over effect displaying the username of the connected user. I found out that I can do that by editing the file

/application/modules/layout/views/layout.php

So, under

<ul class="nav navbar-nav navbar-right">

I added the code:

<li>
  <a href="#" class="tip icon" data-original-title="<?php echo XXX; ?>"
data-placement="bottom">
    <i class="fa fa-question-circle"></i>
    <span class="visible-xs">&nbsp;<?php echo XXX; ?></span>
  </a>
</li>

but I don’t know how to reference the variable user_name and put it instead of XXX.

You could try this but I’m not sure if its working.

Thank you Kovah! This helped a lot! :+1:
The variable is:

$this->session->userdata('user_name')

Here is the complete code snippet:

<li>
	<a href="#" class="tip icon" data-original-title="<?php echo $this->session->userdata('user_name'); ?>" data-placement="bottom">
		<i class="fa fa-question-circle"></i>
		<span class="visible-xs">&nbsp;<?php echo $this->session->userdata('user_name'); ?></span>
	</a>
</li>

And here is the result :slight_smile:

Or even better…

With code:

<li>
	<a href="#" class="tip icon" data-original-title="<?php echo $this->session->userdata('user_name'); ?>" data-placement="bottom">
		<i class="fa fa-user"></i>
		<span class="visible-xs">&nbsp;<?php echo $this->session->userdata('user_name'); ?></span>
	</a>
</li>
2 Likes