Hi guys, first project using Trongate.
I'm working on a small site that uses David's members module from the Module Market to lock down access to all pages to registered members only. The template I'm using has an area to display the logged in person's name. Can I persist it through the view $data or get it from the session data somehow?
Thanks all.
Members Module: Persisting logged in member name right through to the view/template
4 years ago
4 years ago
#1
4 years ago
#2
Hello,
Yes that is possible. Would help to see your controller code.
That said. Here is a good practice.
Always use these two lines of code displaying a view:
These allow you to set Member level in the Trongate_security Module
$this->module('trongate_security');
$this->trongate_security->_make_sure_allowed();
Set Members level in Trongate_users_level
And then get the Member's Object
$member_obj = $this->_get_member_obj();
$data['trongate_user_level'] = $member_obj->user_level_id;
You can use the $data['?????'] = Set your variable or constant to be passed to the view.
Let me know how it goes.
Dan
Yes that is possible. Would help to see your controller code.
That said. Here is a good practice.
Always use these two lines of code displaying a view:
These allow you to set Member level in the Trongate_security Module
$this->module('trongate_security');
$this->trongate_security->_make_sure_allowed();
Set Members level in Trongate_users_level
And then get the Member's Object
$member_obj = $this->_get_member_obj();
$data['trongate_user_level'] = $member_obj->user_level_id;
You can use the $data['?????'] = Set your variable or constant to be passed to the view.
Let me know how it goes.
Dan
4 years ago
#3
Thanks Dan. Sorted it by adding the following to trongate_security.php :
Thanks! ?
[UPDATE] This doesn't 100% work yet - see below for the fix
Thanks! ?
[UPDATE] This doesn't 100% work yet - see below for the fix
4 years ago
#4
That's Great!
I like the way you did that.
Dan
I like the way you did that.
Dan
4 years ago
#5
Ah OK. Scratch that.
I hadn't fully tested it right the way through to the view. Got the username successfully but setting the $data there doesn't seem to carry all the way through to the view.
Fixed it as follows:
in trongate_security.php
and then in the module controller:
I hadn't fully tested it right the way through to the view. Got the username successfully but setting the $data there doesn't seem to carry all the way through to the view.
Fixed it as follows:
in trongate_security.php
and then in the module controller:
4 years ago
#6
You can try this
When you get the trongate_user id
Pass it here
Trongate_user_levels
$this->module('trongate_user_levels');
$this->trongate_user_levels->_get_user_level();
When you get the trongate_user id
Pass it here
Trongate_user_levels
$this->module('trongate_user_levels');
$this->trongate_user_levels->_get_user_level();
4 years ago
#7
Thanks Dan.
That's a little advanced for me just now but it's useful as a reference.
That's a little advanced for me just now but it's useful as a reference.