Passing amember info to PHP variable

Discussion in 'Templates customization' started by goldgoose, Dec 9, 2010.

  1. goldgoose

    goldgoose New Member

    Joined:
    Oct 30, 2010
    Messages:
    6
    I am editing the thanks.html template and I wish to assign the {$member.login} to a php variable ($code). I entered the following, but get an error page.

    <?php

    $code = {$member.login};

    echo strtoupper(substr(str_replace("\r\n","-",(chunk_split("$code",5))),0,-1));
    ?>

    How can I do this correctly?

    Thank you,

    Goose
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    1. In order to use php inside smarty template you need to put code into these tags:
    {php}{/php}
    2. To access template variable, need to use this:
    $this->_tpl_vars['varname'];
    So code should be:
    Code:
    {php}
    $code = $this->_tpl_vars['member']['login'];
    
    echo strtoupper(substr(str_replace("\r\n","-",(chunk_split("$code",5))),0,-1));
    {/php}
    
  3. goldgoose

    goldgoose New Member

    Joined:
    Oct 30, 2010
    Messages:
    6
    Hi Alexander,

    Thank you. That worked.

    Goose

Share This Page