XF 1.4 Code to show something else if logged in ?

CasperB

Member
I have this welcome block that shows no matter what if you are logged in or not. is there some way you can make it show like a welcome message to the logged in user in the same template with some code or something that have to include more then one usergroup ?
 
eg. this code have to show when logged out and something else in the text fields if possible.

Code:
<div class="uix_welcomeBlock_wrap">
    <div class="uix_welcomeBlock_content">
   
        <a href="#" class="close"></a>
   
        <xen:if hascontent="true">
        <h3 class="uix_welcomeBlockHeader">
            <xen:contentcheck>
            <xen:if is="{$uix_welcomeBlockIcon_class}"><i class="uix_icon {$uix_welcomeBlockIcon_class}"></i></xen:if>
            <xen:if is="{$uix_welcomeBlockHeader_text}"><span>{xen:raw $uix_welcomeBlockHeader_text}</span></xen:if>
            </xen:contentcheck>
        </h3>
        </xen:if>
       
        <xen:if is="{$uix_welcomeBlockMessage_text}"><p class="uix_welcomeBlockMessage">{xen:raw $uix_welcomeBlockMessage_text}</p></xen:if>
        <xen:if is="{$uix_welcomeBlockButton_url}"><a href="{$uix_welcomeBlockButton_url}" class="callToAction"><span>{$uix_welcomeBlockButton_text}</span></a></xen:if>

    </div>
</div>
 
missing something ?

The following templates contained errors and were not saved: uix_welcomeBlock_custom: 1) uix_welcomeBlock_custom - Line 8: Invalid if or else if tag: missing is or hascontent attribute.

sorry for asking so much. its over 4 am here
 
Code:
<xen:if is="{$visitor.user_id}">
<div class="uix_welcomeBlock_wrap">
    <div class="uix_welcomeBlock_content">
   
        <a href="#" class="close"></a>
   
       
        <xen:if><h3 class="uix_welcomeBlockHeader">
           
            <i class="uix_icon {$uix_welcomeBlockIcon_class}"></i>
            <span>Welcome to MyGamers</span>
           
        </h3></xen:if>
       
       
        <xen:if><p class="uix_welcomeBlockMessage">You are logged in and ready to use the forum!</p></xen:if>
        <xen:if><a href="http://www.mygamersforum.com/index.php?forums/" class="callToAction"><span>SEE FORUM</span></a></xen:if>

    </div>
</div>
<xen:else />

<div class="uix_welcomeBlock_wrap">
    <div class="uix_welcomeBlock_content">
    <xen:if hascontent="true">
        <a href="#" class="close"></a>
   
       
        <xen:if><h3 class="uix_welcomeBlockHeader">
           
            <i class="uix_icon {$uix_welcomeBlockIcon_class}"></i>
            <span>Welcome to MyGamers</span>
           
        </h3></xen:if>
       
       
        <xen:if><p class="uix_welcomeBlockMessage">Wanting to join the rest of our members? Feel free to sign up today.</p></xen:if>
        <xen:if><a href="http://www.mygamersforum.com/index.php?register" class="callToAction"><span>SIGN UP NOW</span></a></xen:if>

    </div>
</div></xen:if>
 
Code:
<xen:if is="{$visitor.user_id}">
<div class="uix_welcomeBlock_wrap">
    <div class="uix_welcomeBlock_content">
 
        <a href="#" class="close"></a>
 
     
        <xen:if><h3 class="uix_welcomeBlockHeader">
         
            <i class="uix_icon {$uix_welcomeBlockIcon_class}"></i>
            <span>Welcome to MyGamers</span>
         
        </h3></xen:if>
     
     
        <xen:if><p class="uix_welcomeBlockMessage">You are logged in and ready to use the forum!</p></xen:if>
        <xen:if><a href="http://www.mygamersforum.com/index.php?forums/" class="callToAction"><span>SEE FORUM</span></a></xen:if>

    </div>
</div>
<xen:else />

<div class="uix_welcomeBlock_wrap">
    <div class="uix_welcomeBlock_content">
    <xen:if hascontent="true">
        <a href="#" class="close"></a>
 
     
        <xen:if><h3 class="uix_welcomeBlockHeader">
         
            <i class="uix_icon {$uix_welcomeBlockIcon_class}"></i>
            <span>Welcome to MyGamers</span>
         
        </h3></xen:if>
     
     
        <xen:if><p class="uix_welcomeBlockMessage">Wanting to join the rest of our members? Feel free to sign up today.</p></xen:if>
        <xen:if><a href="http://www.mygamersforum.com/index.php?register" class="callToAction"><span>SIGN UP NOW</span></a></xen:if>

    </div>
</div></xen:if>

There are several things wrong with this code. First, you can not use <xen:if> only. It must have a value attached too, so it can check against it.

Second you are missing a closing </xen:if> tag. And as last, you are missing the <xen:contentcheck</xen:contentcheck> tags when you are checking if it contains content.

Here you go. I have fixed it for you. Enjoy.

HTML:
<xen:if is="{$visitor.user_id}">
<div class="uix_welcomeBlock_wrap">
    <div class="uix_welcomeBlock_content">
  
        <a href="#" class="close"></a>
  
      
       <h3 class="uix_welcomeBlockHeader">
          
            <i class="uix_icon {$uix_welcomeBlockIcon_class}"></i>
            <span>Welcome to MyGamers</span>
          
        </h3>
      
      
        <p class="uix_welcomeBlockMessage">You are logged in and ready to use the forum!</p>
        <a href="http://www.mygamersforum.com/index.php?forums/" class="callToAction"><span>SEE FORUM</span></a>

    </div>
</div>
<xen:else />

<div class="uix_welcomeBlock_wrap">
    <div class="uix_welcomeBlock_content">
    <xen:if hascontent="true">
    <xen:contentcheck>
        <a href="#" class="close"></a>
  
      
        <h3 class="uix_welcomeBlockHeader">
          
            <i class="uix_icon {$uix_welcomeBlockIcon_class}"></i>
            <span>Welcome to MyGamers</span>
          
        </h3>
      
      
        <p class="uix_welcomeBlockMessage">Wanting to join the rest of our members? Feel free to sign up today.</p>
        <a href="http://www.mygamersforum.com/index.php?register" class="callToAction"><span>SIGN UP NOW</span></a>
</xen:contentcheck>
    </div>
</div></xen:if></xen:if>
 
Back
Top Bottom