• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

css class conditional

MsJacquiiC

Well-known member
#1
Say for instance I need to code a conditional within a div css class.
If logged in = this class --- If logged out = this class. Something like such:

<div class="this-if-registered" // "this-if-guest">

Wish I could explain it better. Hopefully someone can follow the above.
Is this possible?

J.
 

MsJacquiiC

Well-known member
#7
Thanks so much for the assistance guys.

Curly conditionals are good for this.

{xen:if '{$condition}', 'action_if_true', 'action_if_false'}

So...

<div class="{xen:if '{$visitor.user_id}', 'registered-class', 'guest-class'}">
I think I tried this actually, as someone in another thread suggested. It didn't work correctly. Could have totally been a typo though... But this code works wonderfully = Thanks Chris! ;)

J.
 

Russ

Well-known member
#8
You could also create like a "customguest.css" then throw a conditional in page_container to call the stylesheet if they're a guest. This way instead of individually editing single divs, you put all of them in one style sheet.
 

MsJacquiiC

Well-known member
#9
Nice idea Russ - I just need a quick conditional though, as one of the ads I'm showing to guests only was overlapping the content area. So I had to adjust the min-height attribute only for the message template. Thanks again ya'll!

J.
 

Arty

Well-known member
#10
No need to include extra css file, you can use .LoggedIn to separate css rules for guests and registered users:
Code:
.whatever { for guests; }
.LoggedIn .whatever { for registered users; }