Forums | Mahara Themes

General discussion /
Variables


anonymous profile picture
Account deleted
Posts: 2

03 April 2009, 8:30

Hi!

I'm trying to display the logged in users name in header.tpl. I have tried to get it from the $USER object but the firstname and lastname properties are empty.

I've also tried to see how the name gets displayed in the sidebar but I can't find in what file the variables are set for the profile sideblock.

Can someone give me a hint?

 Regards,

Nils

anonymous profile picture
Account deleted
Posts: 228

03 April 2009, 15:52

Hi!

If you're trying to access variables in smarty templates, it often helps to put

 

{debug} 

 

right at the top of the tpl file.  That will pop up a new window and list all the variables that smarty knows about, and what their values are.

 

anonymous profile picture
Account deleted
Posts: 6

15 June 2010, 8:14

Should {debug} still work in Dwoo (Mahara 1.2.4)?

If I add it to the top of a template I either get just a blank page, or the page loads fine but thre is no difference.

It would be really handy to be able to do something like var_dump(), I presume this is what {debug} should do?

anonymous profile picture
Account deleted
Posts: 1643

03 April 2009, 22:30

The easiest way to do this is:

{$USER|display_name}

anonymous profile picture
Account deleted
Posts: 2

06 April 2009, 3:09

Thanks that worked. What would be the best way to just display the name (remove: ([email protected]))?
anonymous profile picture
Account deleted
Posts: 1643

06 April 2009, 4:05

Hi - that only appears to you because you're an admin for that user (I guess you're a site admin, in which case you'll always see that). Other users will just see either the preferred name, or "firstname lastname" if they don't have a preferred name set.

If it really bothers you, you could probably hack the display_name function in lib/user.php to do what you desired, though it can be useful to know the username of users from time to time - e.g. when it's right next to some abusive content! Smile

anonymous profile picture
Account deleted
Posts: 8

08 January 2010, 10:25

I'm looking for the Moodle login text in Mahara. Any hints? It should like this:

You are logged in as [NAME] (logout)

The [name]  part should link to the profile (as in Moodle) and the logout shoul, well, logout ofcourse...

And when you are not logged in there should be 'you are not logged in (log in)'.

Just like Moodle :)

7 results