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

css class conditional


Formerly MsJacquiiC
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?



Formerly MsJacquiiC
Thanks so much for the assistance guys.

Curly conditionals are good for this.

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


<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! ;)



Well-known member
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.


Formerly MsJacquiiC
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!



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