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.

Make code for guest/logged out users

4 posters

Go down

Solved Make code for guest/logged out users

Post by thefirstdanshin Sun May 26, 2013 11:51 am

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?
avatar
thefirstdanshin
Forumember

Posts : 63
Reputation : 1
Language : English

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by E-Mark Sun May 26, 2013 12: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 Sun May 26, 2013 12:44 pm; edited 1 time in total
E-Mark
E-Mark
Active Poster

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

http://coding-spot.darkbb.com/

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin Sun May 26, 2013 12: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 {

}
avatar
thefirstdanshin
Forumember

Posts : 63
Reputation : 1
Language : English

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by E-Mark Sun May 26, 2013 12: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
}
E-Mark
E-Mark
Active Poster

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

http://coding-spot.darkbb.com/

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin Sun May 26, 2013 1: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 Sun May 26, 2013 1:21 pm; edited 1 time in total
avatar
thefirstdanshin
Forumember

Posts : 63
Reputation : 1
Language : English

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by E-Mark Sun May 26, 2013 1:20 pm

Yes. It is possible, you can put them on viewtopic_body template. Smile
E-Mark
E-Mark
Active Poster

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

http://coding-spot.darkbb.com/

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin Sun May 26, 2013 1: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
avatar
thefirstdanshin
Forumember

Posts : 63
Reputation : 1
Language : English

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by E-Mark Sun May 26, 2013 1: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
E-Mark
E-Mark
Active Poster

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

http://coding-spot.darkbb.com/

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin Sun May 26, 2013 1: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?
avatar
thefirstdanshin
Forumember

Posts : 63
Reputation : 1
Language : English

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by E-Mark Sun May 26, 2013 1: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.
E-Mark
E-Mark
Active Poster

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

http://coding-spot.darkbb.com/

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by Ultron's Vision Sun May 26, 2013 1: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>');

});

}

});
Ultron's Vision
Ultron's Vision
Forumember

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

http://duelacademy.net

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin Sun May 26, 2013 1: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
avatar
thefirstdanshin
Forumember

Posts : 63
Reputation : 1
Language : English

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by Ultron's Vision Sun May 26, 2013 3: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.
Ultron's Vision
Ultron's Vision
Forumember

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

http://duelacademy.net

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin Mon May 27, 2013 9:21 am

 Make code for guest/logged out users Ininkn11
here sir

avatar
thefirstdanshin
Forumember

Posts : 63
Reputation : 1
Language : English

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by Ultron's Vision Mon May 27, 2013 10: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>');

});

}

});
Ultron's Vision
Ultron's Vision
Forumember

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

http://duelacademy.net

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin Mon May 27, 2013 10: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
avatar
thefirstdanshin
Forumember

Posts : 63
Reputation : 1
Language : English

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by Ultron's Vision Mon May 27, 2013 10: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?
Ultron's Vision
Ultron's Vision
Forumember

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

http://duelacademy.net

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin Mon May 27, 2013 10: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
avatar
thefirstdanshin
Forumember

Posts : 63
Reputation : 1
Language : English

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by Ultron's Vision Mon May 27, 2013 10: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?
Ultron's Vision
Ultron's Vision
Forumember

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

http://duelacademy.net

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin Mon May 27, 2013 10:49 am

yup Smile i will do it on my other forum Smile
avatar
thefirstdanshin
Forumember

Posts : 63
Reputation : 1
Language : English

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by Ultron's Vision Mon May 27, 2013 10: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?
Ultron's Vision
Ultron's Vision
Forumember

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

http://duelacademy.net

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin Mon May 27, 2013 12: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
avatar
thefirstdanshin
Forumember

Posts : 63
Reputation : 1
Language : English

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by Ultron's Vision Mon May 27, 2013 12:45 pm

Okay, give me about two hours, I'll have some code written for you, then.
Ultron's Vision
Ultron's Vision
Forumember

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

http://duelacademy.net

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin Mon May 27, 2013 1:45 pm

ok sir, thank you very much Smile
avatar
thefirstdanshin
Forumember

Posts : 63
Reputation : 1
Language : English

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by Ultron's Vision Mon May 27, 2013 1: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>');

});

}

});
Ultron's Vision
Ultron's Vision
Forumember

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

http://duelacademy.net

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin Wed May 29, 2013 11:44 am

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!!!!!!!!!!!!!!!!! :*
avatar
thefirstdanshin
Forumember

Posts : 63
Reputation : 1
Language : English

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by Ultron's Vision Wed May 29, 2013 11:58 am

You're welcome Wink

Don't forget to mark this as solved to simplify the moderators' work Smile
bye
Ultron's Vision
Ultron's Vision
Forumember

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

http://duelacademy.net

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin Wed May 29, 2013 2:03 pm

Ok thank you very much Smile Solved~
avatar
thefirstdanshin
Forumember

Posts : 63
Reputation : 1
Language : English

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by Sir Chivas™ Wed May 29, 2013 2:07 pm

Topic Solved & Locked
Sir Chivas™
Sir Chivas™
Helper
Helper

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

https://aforums.org

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum