Does 'Guest Only' Conditional Work In Extra.CSS?


Well-known member
I want to display advertisement in the first post. I've edited the "message" template to display the advertisement and extra.css to style it.

"message" template code:-

<xen:require css="message.css" />
<xen:require css="bb_code.css" />
<li id="{$messageId}" class="message {xen:if $message.isDeleted, 'deleted'} {xen:if '{$message.is_admin} OR {$message.is_moderator}', 'staff'} {xen:if $message.isIgnored, ignored}" data-author="{$message.username}">
<xen:if is="{$visitor.user_id}">
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0">
<div class="right_block">
<xen:include template="message_user_info">
<xen:map from="$message" to="$user" />
...code continues below...
...and extra.css has -

.messageList .message:first-child .messageInfo.primaryContent { margin-right: 325px; }
.messageList .message:first-child .right_block
height:265px !important;
width:310px !important;
border: 1px solid @primaryLighter;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-khtml-border-radius: 5px;
border-radius: 20px;
text-align: center;
Now the problem:

I plan to use: <xen:if is="{$visitor.user_id}"> conditional to show the advertisement only to guests. However, when a user is logged in, it shows an empty space created by the code in extra.css.

My question is: How can I hide the styling code I've used from logged in users? I've tried using the above 'guests' conditional; but it doesn't seem to work. Or am I doing something wrong?


XenForo moderator
Staff member
Edit the message template to use two different sets of code - one for guests, one for logged in members.

<xen:if is="{$visitor.user_id}">
This content will show to logged in members
<xen:else />
This content will show to guests

Use inline styling or create a separate class for the guest block.


Well-known member
Brogan, can you use xenForo's require statement (<xen:require css="" />) inside a conditional? Maybe he can include css that way conditionally?


Well-known member
Those are actually two lines.

.messageList .message:first-child .messageInfo.primaryContent { margin-right: 325px; }
.messageList .message:first-child .right_block
What I realized is that I'm directly using those elements to style in my extra.css. That results into permanent change in the display of the message text (adds right margin = 325px).

The conditional used in my message template works but that results in showing blank space to my logged in members.

Is there a way I can use different styling for the lines in the above code; by say, wrapping it up in another div or something? (I'm not too familiar with CSS)


Well-known member
Darn! Nothing seems to work. Isn't there a way to really fix this problem? :confused:

Can someone help me create a css 'class' so that I can alter the message element only for the guests?