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

    Make code for guest/logged out users

    avatar
    thefirstdanshin
    Forumember


    Posts : 63
    Reputation : 1
    Language : English

    Solved Make code for guest/logged out users

    Post by thefirstdanshin May 26th 2013, 12:51 pm

    I want to add a CSS Style code for logged out users in my viewtopic_body:

    Code:
    .pun .postmain .user {
    display: none!important;
    }

    Is it possible and where will I add it? in my Template viewtopic_body?
    E-Mark
    E-Mark
    Active Poster


    Male Posts : 1411
    Reputation : 169
    Language : English
    Location : Bitcoin

    Solved Re: Make code for guest/logged out users

    Post by E-Mark May 26th 2013, 1:21 pm

    Just add a tag with class inside the logged out user variable:
    Code:
    <!-- BEGIN switch_user_logged_out --><div class="logged-out">
    Content here
    </div>
    <!-- END switch_user_logged_out -->

    Then for the CSS: (Just put some styles)
    Code:
    .logged-out {

    }


    Last edited by E-Mark on May 26th 2013, 1:44 pm; edited 1 time in total
    avatar
    thefirstdanshin
    Forumember


    Posts : 63
    Reputation : 1
    Language : English

    Solved Re: Make code for guest/logged out users

    Post by thefirstdanshin May 26th 2013, 1:40 pm

    so how would look like sir, like this?

    Code:
    <!-- BEGIN switch_user_logged_out --><div class="logged-out">
    .pun .postmain .user {
    display: none!important;
    }
    </div>
    <!-- END switch_user_logged_out -->


    then CSS

    Code:
    logged-out {

    }
    E-Mark
    E-Mark
    Active Poster


    Male Posts : 1411
    Reputation : 169
    Language : English
    Location : Bitcoin

    Solved Re: Make code for guest/logged out users

    Post by E-Mark May 26th 2013, 1:46 pm

    Nope. It should be like this: (Put this on index_body)
    Code:
    <!-- BEGIN switch_user_logged_out -->
    <div class="logged-out">
    This is the text that will saw by the users who are not yet logged in.
    </div>
    <!-- END switch_user_logged_out -->

    Then on your CSS, put this one:
    Code:
    .logged-out {
    // Put the styles here
    }
    avatar
    thefirstdanshin
    Forumember


    Posts : 63
    Reputation : 1
    Language : English

    Solved Re: Make code for guest/logged out users

    Post by thefirstdanshin May 26th 2013, 2:16 pm

    but i want it on viewtopic_body Sad, is it possible?

    So i would add this:
    Code:
    .logged-out {
    .pun .postmain .user {
    display: none!important;
      }
    }


    Last edited by thefirstdanshin on May 26th 2013, 2:21 pm; edited 1 time in total
    E-Mark
    E-Mark
    Active Poster


    Male Posts : 1411
    Reputation : 169
    Language : English
    Location : Bitcoin

    Solved Re: Make code for guest/logged out users

    Post by E-Mark May 26th 2013, 2:20 pm

    Yes. It is possible, you can put them on viewtopic_body template. Smile
    avatar
    thefirstdanshin
    Forumember


    Posts : 63
    Reputation : 1
    Language : English

    Solved Re: Make code for guest/logged out users

    Post by thefirstdanshin May 26th 2013, 2:26 pm

    here's a photo example sir:

     Make code for guest/logged out users Klhnop10

    and is this the code, that I will add in CSS

    Code:
    .logged-out {
    .pun .postmain .user {
    display: none!important;
      }
    }

    at which part will I add this
    Code:
    <!-- BEGIN switch_user_logged_out -->
    <div class="logged-out">
    This is the text that will saw by the users who are not yet logged in.
    </div>
    <!-- END switch_user_logged_out -->

    to viewtopic_body Sad

    sorry if i have a lot of questions
    E-Mark
    E-Mark
    Active Poster


    Male Posts : 1411
    Reputation : 169
    Language : English
    Location : Bitcoin

    Solved Re: Make code for guest/logged out users

    Post by E-Mark May 26th 2013, 2:32 pm

    Then use the logged in variable instead:
    Code:
    <!-- BEGIN switch_user_logged_in -->
    <div class="logged-out">
    This is the text that will saw by the users who logged in and will not be visible to users who are logged out.
    </div>
    <!-- END switch_user_logged_in -->

    Also, don't use the .pun .postmain .user { as it is considered as redundant of opening tags. Also don't use display: none as it will hide the content of the class connected to it. Smile
    avatar
    thefirstdanshin
    Forumember


    Posts : 63
    Reputation : 1
    Language : English

    Solved Re: Make code for guest/logged out users

    Post by thefirstdanshin May 26th 2013, 2:36 pm

    uhmm, sir, that's kind of my purpose to hide
    .pun .postmain .user {

    i want to hide it from Guests Smile how can it be done?
    E-Mark
    E-Mark
    Active Poster


    Male Posts : 1411
    Reputation : 169
    Language : English
    Location : Bitcoin

    Solved Re: Make code for guest/logged out users

    Post by E-Mark May 26th 2013, 2:42 pm

    Then just use this one:
    Code:
    <!-- BEGIN switch_user_logged_in -->
    This is the text that will saw by the users who logged in and will not be visible to users who are logged out.
    <!-- END switch_user_logged_in -->

    The <!-- BEGIN switch_user_logged_in --> / <!-- END switch_user_logged_in --> will automatically hide the content inside it to guest users.
    Ultron's Vision
    Ultron's Vision
    Forumember


    Male Posts : 631
    Reputation : 45
    Language : English | German | HTML | JavaScript | PHP | C++ | Perl | Java
    Location : Vienna, Austria

    Solved Re: Make code for guest/logged out users

    Post by Ultron's Vision May 26th 2013, 2:42 pm

    Try using this JavaScript if you don't want to edit templates, add it under Administration Panel -> Modules -> HTML & JavaScript -> JavaScript pages management -> Create a new JavaScript.

    Code:
    jQuery(document).ready(function(){

    if(!jQuery('#logout')){

    jQuery('.pun .postmain .user').each(function(){

    jQuery(this).replaceWith('<span style="font-weight: bold; color: #ff1010; text-align: center;">You must be logged in to view this content.</span>');

    });

    }

    });
    avatar
    thefirstdanshin
    Forumember


    Posts : 63
    Reputation : 1
    Language : English

    Solved Re: Make code for guest/logged out users

    Post by thefirstdanshin May 26th 2013, 2:50 pm

    @Ultron's Vision: it doesn't quite work, you can still see it here: http://ggpalace.forumotion.net/t1603-2013-sunny-s-birthday-message-thread

    Please help me Sad
    Ultron's Vision
    Ultron's Vision
    Forumember


    Male Posts : 631
    Reputation : 45
    Language : English | German | HTML | JavaScript | PHP | C++ | Perl | Java
    Location : Vienna, Austria

    Solved Re: Make code for guest/logged out users

    Post by Ultron's Vision May 26th 2013, 4:02 pm

    Would you do me a favor?
    Hover over the 'Register' link and then right-click and click on Inspect Element, then copy what the browser outputs (preferably, use Chrome so you can take a screenshot of the console in case you don't know what to do) in here (I'm looking for the CSS Selector for the Register link) so I can optimize my code above.
    avatar
    thefirstdanshin
    Forumember


    Posts : 63
    Reputation : 1
    Language : English

    Solved Re: Make code for guest/logged out users

    Post by thefirstdanshin May 27th 2013, 10:21 am

     Make code for guest/logged out users Ininkn11
    here sir

    Ultron's Vision
    Ultron's Vision
    Forumember


    Male Posts : 631
    Reputation : 45
    Language : English | German | HTML | JavaScript | PHP | C++ | Perl | Java
    Location : Vienna, Austria

    Solved Re: Make code for guest/logged out users

    Post by Ultron's Vision May 27th 2013, 11:16 am

    Okay, take the code I posted above and replace it with this.

    Code:
    jQuery(document).ready(function(){

    if($('a[href="/register"]')){

    $('.pun .postmain .user').each(function(){

    $(this).replaceWith('<span style="text-align: center; color: #ff1010; font-weight: bold; text-decoration: underline;">You must be registered and logged in to view this content.</span>');

    });

    }

    });
    avatar
    thefirstdanshin
    Forumember


    Posts : 63
    Reputation : 1
    Language : English

    Solved Re: Make code for guest/logged out users

    Post by thefirstdanshin May 27th 2013, 11:25 am

    Sir, it works , but I can still see this
    You must be registered to view this content.

    even if I'm logged in
    Ultron's Vision
    Ultron's Vision
    Forumember


    Male Posts : 631
    Reputation : 45
    Language : English | German | HTML | JavaScript | PHP | C++ | Perl | Java
    Location : Vienna, Austria

    Solved Re: Make code for guest/logged out users

    Post by Ultron's Vision May 27th 2013, 11:33 am

    Errr, so I guess that even registered users see the register link somewhere on your site.

    Could you provide a test admin account to me via PM so that I can inspect the site and post a new code for you?
    avatar
    thefirstdanshin
    Forumember


    Posts : 63
    Reputation : 1
    Language : English

    Solved Re: Make code for guest/logged out users

    Post by thefirstdanshin May 27th 2013, 11:37 am

    yes sir, Even registered users see the "You must be logged in.."
    Code:
    jQuery(document).ready(function(){

    if($('a[href="/register"]')){

    $('.pun .postmain .user').each(function(){

    $(this).replaceWith('<span style="text-align: center; color: #ff1010; font-weight: bold; text-decoration: underline;">You must be registered and logged in to view this content.</span>');

    });

    }

    });

    this works perfectly sir, only registered users see it also...


    EDIT: Oh sorry for the trouble sir, thank you for helping Smile Topic Solved
    Ultron's Vision
    Ultron's Vision
    Forumember


    Male Posts : 631
    Reputation : 45
    Language : English | German | HTML | JavaScript | PHP | C++ | Perl | Java
    Location : Vienna, Austria

    Solved Re: Make code for guest/logged out users

    Post by Ultron's Vision May 27th 2013, 11:47 am

    thefirstdanshin wrote:yes sir, Even registered users see the "You must be logged in.."
    Code:
    jQuery(document).ready(function(){

    if($('a[href="/register"]')){

    $('.pun .postmain .user').each(function(){

    $(this).replaceWith('<span style="text-align: center; color: #ff1010; font-weight: bold; text-decoration: underline;">You must be registered and logged in to view this content.</span>');

    });

    }

    });

    this works perfectly sir, only registered users see it also...


    EDIT: Oh sorry for the trouble sir, thank you for helping Smile Topic Solved

    So it is working for you?
    avatar
    thefirstdanshin
    Forumember


    Posts : 63
    Reputation : 1
    Language : English

    Solved Re: Make code for guest/logged out users

    Post by thefirstdanshin May 27th 2013, 11:49 am

    yup Smile i will do it on my other forum Smile
    Ultron's Vision
    Ultron's Vision
    Forumember


    Male Posts : 631
    Reputation : 45
    Language : English | German | HTML | JavaScript | PHP | C++ | Perl | Java
    Location : Vienna, Austria

    Solved Re: Make code for guest/logged out users

    Post by Ultron's Vision May 27th 2013, 11:57 am

    Glad to be of help Smile

    Just so that I have it confirmed -- the code is working, and registered users are not affected by the code, did I get that right?
    avatar
    thefirstdanshin
    Forumember


    Posts : 63
    Reputation : 1
    Language : English

    Solved Re: Make code for guest/logged out users

    Post by thefirstdanshin May 27th 2013, 1:36 pm

    the registered users are still affected though, but I just removed the text:
    You must be registered and logged in to view this content and it was fine Smile thanks
    Ultron's Vision
    Ultron's Vision
    Forumember


    Male Posts : 631
    Reputation : 45
    Language : English | German | HTML | JavaScript | PHP | C++ | Perl | Java
    Location : Vienna, Austria

    Solved Re: Make code for guest/logged out users

    Post by Ultron's Vision May 27th 2013, 1:45 pm

    Okay, give me about two hours, I'll have some code written for you, then.
    avatar
    thefirstdanshin
    Forumember


    Posts : 63
    Reputation : 1
    Language : English

    Solved Re: Make code for guest/logged out users

    Post by thefirstdanshin May 27th 2013, 2:45 pm

    ok sir, thank you very much Smile
    Ultron's Vision
    Ultron's Vision
    Forumember


    Male Posts : 631
    Reputation : 45
    Language : English | German | HTML | JavaScript | PHP | C++ | Perl | Java
    Location : Vienna, Austria

    Solved Re: Make code for guest/logged out users

    Post by Ultron's Vision May 27th 2013, 2:57 pm

    So after registering, I found a detail which is unique to guests.

    Delete all the previous codes I gave you and type this in a new JavaScript under Administration Panel -> Modules -> HTML & JavaScript -> JavaScript pages management -> Create a new JavaScript.

    Code:
    $(document).ready(function(){

    if($('img#i_icon_mini_login')){

    $('.pun .postmain .user').each(function(){

    $(this).replaceWith('<span style="text-align: center; color: #ff1010; font-weight: bold; text-decoration: none !important;">You must be registered and logged in to view this content.</span>');

    });

    }

    });
    avatar
    thefirstdanshin
    Forumember


    Posts : 63
    Reputation : 1
    Language : English

    Solved Re: Make code for guest/logged out users

    Post by thefirstdanshin May 29th 2013, 12:44 pm

    WOW~ this one really works Smile i thought it doesn't, I was using IE as my browser, turned out the Jscript was off Smile now it works, i'm using chrome Smile Thank you very very very much!!!!!!!!!!!!!!!!! :*
    Ultron's Vision
    Ultron's Vision
    Forumember


    Male Posts : 631
    Reputation : 45
    Language : English | German | HTML | JavaScript | PHP | C++ | Perl | Java
    Location : Vienna, Austria

    Solved Re: Make code for guest/logged out users

    Post by Ultron's Vision May 29th 2013, 12:58 pm

    You're welcome Wink

    Don't forget to mark this as solved to simplify the moderators' work Smile
    bye
    avatar
    thefirstdanshin
    Forumember


    Posts : 63
    Reputation : 1
    Language : English

    Solved Re: Make code for guest/logged out users

    Post by thefirstdanshin May 29th 2013, 3:03 pm

    Ok thank you very much Smile Solved~
    Sir Chivas™
    Sir Chivas™
    Helper
    Helper


    Male Posts : 6980
    Reputation : 457
    Language : EN, FR, ES
    Location : || CSS || HTML || Graphics Designs || Support ||

    Solved Re: Make code for guest/logged out users

    Post by Sir Chivas™ May 29th 2013, 3:07 pm

    Topic Solved & Locked

      Current date/time is September 22nd 2024, 11:21 pm