The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
4 posters

    How do I create things which can only be viewed by either logged in or logged out users?

    medusa
    medusa
    Forumember


    Female Posts : 52
    Reputation : 1
    Language : Danish, English
    Location : Denmark

    In progress How do I create things which can only be viewed by either logged in or logged out users?

    Post by medusa March 6th 2015, 6:58 am

    Hallooo everyone Smile

    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 Smile

    Sorry if you don't understand what I'm trying to say, I think it is hard to explain ^^

    Yours
    Medusa
    medusa
    medusa
    Forumember


    Female Posts : 52
    Reputation : 1
    Language : Danish, English
    Location : Denmark

    In progress Re: How do I create things which can only be viewed by either logged in or logged out users?

    Post by medusa March 8th 2015, 2:34 pm

    Bump Smile
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    In progress Re: How do I create things which can only be viewed by either logged in or logged out users?

    Post by TheCrow March 8th 2015, 8:09 pm

    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.! Smile

    Luffy



    How do I create things which can only be viewed by either logged in or logged out users? Thecro10
     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!
    medusa
    medusa
    Forumember


    Female Posts : 52
    Reputation : 1
    Language : Danish, English
    Location : Denmark

    In progress Re: How do I create things which can only be viewed by either logged in or logged out users?

    Post by medusa March 9th 2015, 8:39 am

    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? ^^
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    In progress Re: How do I create things which can only be viewed by either logged in or logged out users?

    Post by TheCrow March 9th 2015, 8:42 am

    Hello,

    You want to add a widget that will be a menu or you want to add an other menu at the right side?



    How do I create things which can only be viewed by either logged in or logged out users? Thecro10
     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!
    medusa
    medusa
    Forumember


    Female Posts : 52
    Reputation : 1
    Language : Danish, English
    Location : Denmark

    In progress Re: How do I create things which can only be viewed by either logged in or logged out users?

    Post by medusa March 13th 2015, 9:44 am

    Hallo @Luffy

    Our menu is made within a customized-widget(just a plain widget), the ones forumotions provides Smile
    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 ^^
    medusa
    medusa
    Forumember


    Female Posts : 52
    Reputation : 1
    Language : Danish, English
    Location : Denmark

    In progress Re: How do I create things which can only be viewed by either logged in or logged out users?

    Post by medusa March 15th 2015, 4:45 am

    bump
    AuQaClan
    AuQaClan
    Forumember


    Male Posts : 283
    Reputation : 5
    Language : english

    In progress Re: How do I create things which can only be viewed by either logged in or logged out users?

    Post by AuQaClan March 15th 2015, 5:26 am

    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
    medusa
    medusa
    Forumember


    Female Posts : 52
    Reputation : 1
    Language : Danish, English
    Location : Denmark

    In progress Re: How do I create things which can only be viewed by either logged in or logged out users?

    Post by medusa March 16th 2015, 3:12 am

    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. Smile
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    In progress Re: How do I create things which can only be viewed by either logged in or logged out users?

    Post by Ange Tuteur March 16th 2015, 3:46 am

    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 :
    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 bye

      Current date/time is November 11th 2024, 2:20 pm