Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Cannot get data out of grav.user

Started by Muut Archive 10 years ago · 2 replies · 472 views
10 years ago

I have been looking for documentation on variables that I can use in twig for my template, and there doesn't seem to be much available. I figured, based on how the login plugin displays

welcome {{ grav.user.username }}

I would be able to use that variable, but I can't seem to get any output from it. I am logged in as a super user, and am really trying to get a true or false if the current user has access to the admin panel, that way I can create a link in the header to take me there without having to type /admin in the address bar everytime. However, I can't even get it to output my username. Am I using this wrong?

I tried in my theme to insert

TWIG
<pre> {{ dump(grav.user) }} </pre>

and that got me nowhere. Any advice?

Thanks,

-Josh-

10 years ago

I'm assuming i'm already talking to you on our Gitter.im chat. Let me know if that is not the case :)

10 years ago

Yes, that is correct. Thanks for the help. If anyone else runs into this, the first thing ot note is that Grav pipes the dump command to the debug bar, so you'll have to enable it, as noted here: http://learn.getgrav.org/advanced/debugging#debug-bar

That should get you going on debugging variables in grav.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1354 9 years ago
Archive · by Muut Archive, 9 years ago
2 935 9 years ago
Archive · by Muut Archive, 9 years ago
2 4064 9 years ago
Archive · by Muut Archive, 9 years ago
1 2951 9 years ago
Archive · by Muut Archive, 9 years ago
3 1119 9 years ago