1
Arowana
IF Statement in template
  • 2011/1/22 0:38

  • Arowana

  • Friend of XOOPS

  • Posts: 323

  • Since: 2004/8/6 2


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

2
Mamba
Re: IF Statement in template
  • 2011/1/22 1:05

  • Mamba

  • Moderator

  • Posts: 11245

  • Since: 2004/4/23


Try:

<{if $xoops_isuser}>


    <{else}>
 

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

3
redheadedrod
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

4
Balzac
Re: IF Statement in template
  • 2011/1/22 1:18

  • Balzac

  • Just popping in

  • Posts: 68

  • Since: 2010/1/11


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.

5
Arowana
Re: IF Statement in template
  • 2011/1/22 1:21

  • Arowana

  • Friend of XOOPS

  • Posts: 323

  • Since: 2004/8/6 2


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

6
Balzac
Re: IF Statement in template
  • 2011/1/22 9:48

  • Balzac

  • Just popping in

  • Posts: 68

  • Since: 2010/1/11


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.

7
Arowana
Re: IF Statement in template
  • 2011/1/22 20:38

  • Arowana

  • Friend of XOOPS

  • Posts: 323

  • Since: 2004/8/6 2


<{if $xoops_isuser}> 

Display if logged in  or nothing at all  

    
<{/if}>
Arowana

Login

Username:
Password:

Lost Password? Register now!

Who's Online

66 user(s) are online (38 user(s) are browsing Support Forums)


Members: 0


Guests: 66


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits