xoops forums

Arowana

Friend of XOOPS
Posted on: 2011/1/22 0:38
Arowana
Arowana (Show more)
Friend of XOOPS
Posts: 323
Since: 2004/8/6 2
#1

IF Statement in template

I have a module and there is info i do not want to publicly share. I want to show it if the user is logged in only.

do you know the template code for "IF user logged in show <td>show if logged in</td>else skip / end




Arowana

Mamba

Moderator
Posted on: 2011/1/22 1:05
Mamba
Mamba (Show more)
Moderator
Posts: 10988
Since: 2004/4/23
#2

Re: IF Statement in template

Try:

<{if $xoops_isuser}>


    <{else}>
 

    <{/if}>
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

redheadedrod

Home away from home
Posted on: 2011/1/22 1:06
redheadedrod
redheadedrod (Show more)
Home away from home
Posts: 1296
Since: 2008/2/26
#3

Re: IF Statement in template

In templates/xroster_index_template.html...

I have the following code in mine... I will show the code block for this section and you should be able to figure out how it works...

Showing the whole block so you can see where I changed and what I changed.

<{elseif ($pop == "view_member")}>

      <
table cellpadding="0" cellspacing="0" width="80%">
        <
tr>
            <
td class="itemHead"><span class="itemTitle"><h1><CENTER><{$member.realname}></CENTER></h1></span></td>
        </
tr></table></br> </br>
  <
table width="80%" align="center" cellspacing="8" cellpadding="8" class="outer">
    <
tr>
      <
td align="left">
        <{if 
$member.picture}>
          <
img align="right" src="<{$member.picture}>" alt="<{$member.realname}>" height=200px>
        <{/if}>
        <
b>Position:</b> <{$member.spositions}><br><br>
        <
b>Height:</b> <{$member.sheight}><br><br>
        <
b>Weight:</b> <{$member.sweight}><br><br>
        <
b>Jersey Number:</b> <{$member.jnumber}><br><br>
       <{if 
$member.school}><b>School:</b> <{$member.school}><br><br><{/if}>
       <
b>Experience (Pro/Semi-pro):</b><{if $member.exper}> <{$member.exper}> years<br><br><{else}> Rookie<{/if}>
       <
b>Birthdate:         </b> <{$member.bdate}><br><br>
      <{if 
$xoops_isadmin}>
           <{if 
$member.email}><b>Email:        </b><a href="mailto:<{$member.email}>"><{$member.email}></a><br><br><{/if}>
           <{if 
$member.phone}><b>Phone Number: </b> <{$member.phone}><br><br><{/if}>
           <{if 
$member.address}><b>Street: </b> <{$member.address}><br><br><{/if}>
           <
b>CityState zip: </b> <{$member.city}>, <{$member.pstate}>  <{$member.zipcode}><br><br>
      <{else}>
        <
b>Hometown:         </b> <{$member.city}>, <{$member.pstate}><br><br>
      <{/if}>       
      </
td>
    </
tr>
      </
table>
   <
table cellpadding="0" cellspacing="0" width="80%">
    <
tr>
        <
td class="itemFoot"><span class="itemTitle"><CENTER><a href="index.php"><{$lang_back}></a></CENTER></span></td>
    </
tr></table>
<{/if}>


I believe the code you want will be similar to what I used for

<{if $xoops_isadmin}>


But the right smarty tag is $xoops_isuser I believe. Someone please correct me if I am wrong.

Rodney

Balzac

Just popping in
Posted on: 2011/1/22 1:18
Balzac
Balzac (Show more)
Just popping in
Posts: 68
Since: 2010/1/11
#4

Re: IF Statement in template

Below works if the text will be entered with the standard editor within xoops.
The below code is usable within every module when you enter text by standard xoops editor.

Add BBcode [hide]your text hide for guests, but visible for logged registered users[/hide]
Text within hide brackets will only be visible for logged in registered users.

Open: xoops/class/module.textsanitizer.php
Look for line 344
function xoopsCodeDecode$text$allowimage )
     {
         
$patterns = array();
         
$replacements = array();


Replace the above code with
function &xoopsCodeDecode(&$text$allowimage 1)
    {
    
$patterns = array();
    
$replacements = array();
    
$patterns[] = "/[hide](.*)[/hide]/sU";
    if(
$_SESSION['xoopsUserId']) {
    
$replacements[] = '\1';
    }
    else {
    
$replacements[] = '<a href="'.XOOPS_URL.'/register.php"><img src="'.XOOPS_URL.'/images/hidden.gif" alt="only visible for registered users" /></a>';
    }


This is an old trick I grabbed somewhere. Don't know where I got it from but saved it.
Cannot garanteu if this trick still works.
Dont forget to upload a new image hidden.gif in the appropiate dir.
Otherwise mamba's code works very well.

Arowana

Friend of XOOPS
Posted on: 2011/1/22 1:21
Arowana
Arowana (Show more)
Friend of XOOPS
Posts: 323
Since: 2004/8/6 2
#5

Re: IF Statement in template

Sweet Worked like a charm! Thanks everyone, nice to feel the love again!
Arowana

Balzac

Just popping in
Posted on: 2011/1/22 9:48
Balzac
Balzac (Show more)
Just popping in
Posts: 68
Since: 2010/1/11
#6

Re: IF Statement in template

Quote:
Sweet Worked like a charm! Thanks everyone

Which outhanded code did you use and worked like a charm? Would be nice to inform the community.

Arowana

Friend of XOOPS
Posted on: 2011/1/22 20:38
Arowana
Arowana (Show more)
Friend of XOOPS
Posts: 323
Since: 2004/8/6 2
#7

Re: IF Statement in template

<{if $xoops_isuser}> 

Display if logged in  or nothing at all  

    
<{/if}>
Arowana