some php and smarty help?

Discussion in 'Customization & add-ons' started by jasondavis, Jul 6, 2005.

  1. jasondavis

    jasondavis New Member

    Joined:
    Aug 1, 2003
    Messages:
    85
    Im new to php so maybe this is so simple you could point me in a direction a little closer
    What im trying to do is something like this maybe in my profile.php file


    //site thumbnail check////////////
    $filename = "sitethumbs/".$user['login'].".jpg";
    if (file_exists($filename)) {
    } else {
    $t->assign('sitethumbs', $filename);
    }
    /////end////////////



    then I have a file called viewprofile.html which uses the profile.php with
    smarty templates so in this file I use


    {if ($sitethumbs)}
    <img src="members/sitethumbs/thumbs/{$user.login}.jpg" border="0"
    width="145" alt="Visit {$user.login}'s website">
    {/if}



    Basicly in the template file it is always showing ($sitethumbs) and I want it to only show ($sitethumbs) if the file exist
  2. Regs

    Regs New Member

    Joined:
    May 5, 2003
    Messages:
    30
    Hi Jason,

    I'm no php guru myself but thought perhaps this might help:

    Code:
    //site thumbnail check////////////
    $filename = "sitethumbs/".$user['login'].".jpg";
    if (!file_exists($filename)) {
    $t->assign('sitethumbs', $filename);
    }
    /////end////////////
    It shortens your code (a good thing) by changing the conditional check to just a not (by putting an exclamation before the file_exists command).

    Try that and see if it helps... if it does, great as this would be the first time I've ever helped someone else other than myself when it comes to this stuff :D

    Cheers,

    ~Regs.
  3. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    replace line
    {if ($sitethumbs)}
    to
    {if $sitethumbs ne ""}

Share This Page