1. 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?

Discussion in 'Styling and Customization Questions' started by TheBigK, Mar 13, 2012.

  1. TheBigK

    TheBigK 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?
  2. Rob

    Rob Well-Known Member

    <xen:if is="!{$visitor.user_id}"> is correct..... i assume it wont work in css
  3. TheBigK

    TheBigK Well-Known Member

    But extra.css is a template; right? It should work!
  4. TheBigK

    TheBigK Well-Known Member

  5. Forsaken

    Forsaken Well-Known Member

  6. TheBigK

    TheBigK Well-Known Member

    Oh well, thanks for your response.

    Can someone help me with the problem? Please :sick:
  7. Rob

    Rob Well-Known Member

    There will definitly be a way but off hand I dont know of another conditional to test
  8. Brogan

    Brogan 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.
  9. Rob

    Rob 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?
  10. TheBigK

    TheBigK Well-Known Member

    I'm not sure how can I use

    in my styling?
  11. Rob

    Rob Well-Known Member

    is it just the one line?

    Cant you just include it in extra.css unconditionally?
  12. TheBigK

    TheBigK 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)
  13. TheBigK

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

Share This Page