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

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

TheBigK

Well-known member
#1
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:-

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">
<ADVRTISEMENT CODE GOES HERE>
</div>
</xen:if>
</xen:if>
<xen:include template="message_user_info">
<xen:map from="$message" to="$user" />
.
.
...code continues below...
...and extra.css has -

Code:
.messageList .message:first-child .messageInfo.primaryContent { margin-right: 325px; }
.messageList .message:first-child .right_block
{
display:block;
float:right;
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?
 

Brogan

XenForo moderator
Staff member
#8
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
</xen:if>

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

Rob

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

TheBigK

Well-known member
#12
Those are actually two lines.

Code:
.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)
 

TheBigK

Well-known member
#13
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?