How do I create things which can only be viewed by either logged in or logged out users?
4 posters
Page 1 of 1
How do I create things which can only be viewed by either logged in or logged out users?
Hallooo everyone
Me and my admins have begun to create our own "menu", like the one of the head of every forum where you can have the functions for login, logout, FAQ, portal, member, search and so on.
Our menu is going to be on the side of the forum like a widget.
but how do we create the same "function" for login, logout and create new user and such
because we want it to be like normally that if you are logged out then you can see the login and create user buttons, and if you are logged in then you can only see logout button
Sorry if you don't understand what I'm trying to say, I think it is hard to explain ^^
Yours
Medusa
Me and my admins have begun to create our own "menu", like the one of the head of every forum where you can have the functions for login, logout, FAQ, portal, member, search and so on.
Our menu is going to be on the side of the forum like a widget.
but how do we create the same "function" for login, logout and create new user and such
because we want it to be like normally that if you are logged out then you can see the login and create user buttons, and if you are logged in then you can only see logout button
Sorry if you don't understand what I'm trying to say, I think it is hard to explain ^^
Yours
Medusa
Re: How do I create things which can only be viewed by either logged in or logged out users?
Hello @medusa,
While creating the menu you need to add some rules before the links you want to be visible for those who are online and an other rule for the links for those who are offline.
Here are the rules you need to add to your template:
<!-- BEGIN switch_user_logged_in -->
links for logged in
<!-- END switch_user_logged_in -->
<!-- BEGIN switch_user_logged_out -->
links for logged out
<!-- END switch_user_logged_out -->
If you use these rules then the links in logged_in rule will be visible only for those that have logged in and the links in logged_out rule will be visible for guests and not to those who are logged in.!
Luffy
While creating the menu you need to add some rules before the links you want to be visible for those who are online and an other rule for the links for those who are offline.
Here are the rules you need to add to your template:
<!-- BEGIN switch_user_logged_in -->
links for logged in
<!-- END switch_user_logged_in -->
<!-- BEGIN switch_user_logged_out -->
links for logged out
<!-- END switch_user_logged_out -->
If you use these rules then the links in logged_in rule will be visible only for those that have logged in and the links in logged_out rule will be visible for guests and not to those who are logged in.!
Luffy
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
Re: How do I create things which can only be viewed by either logged in or logged out users?
Many thanks for your solution ^^
Sadly I must say that our admins are not competent enough to understand the code system of templates(We are only selftaught programmers)
and we are making our menu with hmtl in the widget itself and some css kodes.
So is there a way of using hmtl? instead of templates? ^^
Sadly I must say that our admins are not competent enough to understand the code system of templates(We are only selftaught programmers)
and we are making our menu with hmtl in the widget itself and some css kodes.
So is there a way of using hmtl? instead of templates? ^^
Re: How do I create things which can only be viewed by either logged in or logged out users?
Hello,
You want to add a widget that will be a menu or you want to add an other menu at the right side?
You want to add a widget that will be a menu or you want to add an other menu at the right side?
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
Re: How do I create things which can only be viewed by either logged in or logged out users?
Hallo @Luffy
Our menu is made within a customized-widget(just a plain widget), the ones forumotions provides
Where we use hmtl within the widget itself through the administrationpanel and then some css codes because we have a dropdown menu. But not that it really matters, I just want to hear if we can use a special kind of HMTL code of this function which I requested ^^
Our menu is made within a customized-widget(just a plain widget), the ones forumotions provides
Where we use hmtl within the widget itself through the administrationpanel and then some css codes because we have a dropdown menu. But not that it really matters, I just want to hear if we can use a special kind of HMTL code of this function which I requested ^^
Re: How do I create things which can only be viewed by either logged in or logged out users?
You should try maybe adding something like > https://help.forumotion.com/t132126-phpbb2-have-a-vertical-navigation-bar
As then you can simple edit in what luffy wrote to hide certain things, although i do-not use Phpbb2
As then you can simple edit in what luffy wrote to hide certain things, although i do-not use Phpbb2
Re: How do I create things which can only be viewed by either logged in or logged out users?
Sadly I cannot use that one because we have other things in our menu which the normal menu/bar does not contain ^^ Also dropdown menu effects and such
But else thanks for the solution, sadly we can't use it.
But else thanks for the solution, sadly we can't use it.
Re: How do I create things which can only be viewed by either logged in or logged out users?
Hi @medusa,
A simple method I could come up with you would be to use JavaScript, since you're not able to use the template tags. Go to Administration Panel > Modules > JavaScript codes management > Create a new script
Placement : In all the pages
Paste the following code and click submit :
This will then allow you to add special classnames to elements you want shown based on the user state. If I wanted something only shown for logged in members I can do the following :
As you can see, I've applied the class class="fa_logged_in". The script will hide elements with this class while logged out, but will show them while logged in. If JS is disabled however, the elements will render as their default state depending if you've hidden them with CSS or not.
The classes you can use are :
fa_logged_in : shows elements with this class only while logged in.
fa_logged_out : shows elements with this class only while logged out.
You can also add multiple classes by separating them with a space, just so you know.
If any questions, let me know.
See you
A simple method I could come up with you would be to use JavaScript, since you're not able to use the template tags. Go to Administration Panel > Modules > JavaScript codes management > Create a new script
Placement : In all the pages
Paste the following code and click submit :
- Code:
$(function() {
if (_userdata.session_logged_in) {
$('.fa_logged_in').show()
$('.fa_logged_out').hide();
} else {
$('.fa_logged_in').hide()
$('.fa_logged_out').show();
}
});
This will then allow you to add special classnames to elements you want shown based on the user state. If I wanted something only shown for logged in members I can do the following :
- Code:
<a class="fa_logged_in" href="/login?logout=1">My logout button</a>
As you can see, I've applied the class class="fa_logged_in". The script will hide elements with this class while logged out, but will show them while logged in. If JS is disabled however, the elements will render as their default state depending if you've hidden them with CSS or not.
The classes you can use are :
fa_logged_in : shows elements with this class only while logged in.
fa_logged_out : shows elements with this class only while logged out.
You can also add multiple classes by separating them with a space, just so you know.
- Code:
<a class="mainmenu fa_logged_in" href="/login?logout=1">My logout button</a>
<a class="mainmenu fa_logged_out" href="/login">My login button</a>
If any questions, let me know.
See you
Similar topics
» Money taken from logged in, gullible, forum users by spam advertising
» Says 0 users online when I'm not logged in and when others are not
» Requiring users to be logged in to see threads
» How to create permission (No write & reply for some users)
» Make code for guest/logged out users
» Says 0 users online when I'm not logged in and when others are not
» Requiring users to be logged in to see threads
» How to create permission (No write & reply for some users)
» Make code for guest/logged out users
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum