The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Make code for guest/logged out users

View previous topic View next topic Go down

Solved Make code for guest/logged out users

Post by thefirstdanshin on 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?

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 on 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

E-Mark
Active Poster

Male Posts : 1389
Reputation : 164
Language : English, Tagalog
Location : Republic of the Philippines

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

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin on 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 {

}

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 on 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
}

E-Mark
Active Poster

Male Posts : 1389
Reputation : 164
Language : English, Tagalog
Location : Republic of the Philippines

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

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin on 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

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 on May 26th 2013, 2:20 pm

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

E-Mark
Active Poster

Male Posts : 1389
Reputation : 164
Language : English, Tagalog
Location : Republic of the Philippines

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

Back to top Go down

Solved Re: Make code for guest/logged out users

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

here's a photo example sir:



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

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 on 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

E-Mark
Active Poster

Male Posts : 1389
Reputation : 164
Language : English, Tagalog
Location : Republic of the Philippines

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

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by thefirstdanshin on 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?

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 on 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.

E-Mark
Active Poster

Male Posts : 1389
Reputation : 164
Language : English, Tagalog
Location : Republic of the Philippines

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

Back to top Go down

Solved Re: Make code for guest/logged out users

Post by Ultron's Vision on 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>');

});

}

});

Ultron's Vision
Forumember

Male Posts : 634
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 on 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

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 on 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.

Ultron's Vision
Forumember

Male Posts : 634
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 on May 27th 2013, 10:21 am


here sir


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 on 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>');

});

}

});

Ultron's Vision
Forumember

Male Posts : 634
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 on 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

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 on 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?

Ultron's Vision
Forumember

Male Posts : 634
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 on 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

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 on 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?

Ultron's Vision
Forumember

Male Posts : 634
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 on May 27th 2013, 11:49 am

yup Smile i will do it on my other forum Smile

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 on 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?

Ultron's Vision
Forumember

Male Posts : 634
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 on 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

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 on May 27th 2013, 1:45 pm

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

Ultron's Vision
Forumember

Male Posts : 634
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 on May 27th 2013, 2:45 pm

ok sir, thank you very much Smile

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 on 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>');

});

}

});

Ultron's Vision
Forumember

Male Posts : 634
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 on 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!!!!!!!!!!!!!!!!! :*

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 on 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

Ultron's Vision
Forumember

Male Posts : 634
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 on May 29th 2013, 3:03 pm

Ok thank you very much Smile Solved~

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™ on May 29th 2013, 3:07 pm

Topic Solved & Locked



Attention!
- Please provide your forum URL at all times.
- When the issue is solved, please mark it as solved.



Sir Chivas™
Support Moderator
Support Moderator

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

Back to top Go down

View previous topic View next topic Back to top


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