PHP smarty variable error

2019-08-18 01:24发布

I have this error

" NOTICE: UNDEFINED VARIABLE: LOGO IN C:\WAMP\WWW\SITE\TOOLS\SMARTY\SYSPLUGINS\SMARTY_INTERNAL_DATA.PHP ON LINE 291 CALL STACK"

Here is my PHP code

function hookFooter($params)
{
    global $smarty;
    $smarty->assign('ENT_QUOTES', ENT_QUOTES);
    if( file_exists('modules/ebbrandingfooter/logo-footer.jpg')){
        $smarty->assign('logo','modules/ebbrandingfooter/logo-footer.jpg');
    };
    $FOOTERdescription=Configuration::get('FOOTER_DESC');
    $smarty->assign('description',$FOOTERdescription );
    return $this->display(__FILE__, 'ebbrandingfooter.tpl');
}

And Here the TPL

  {if $logo}<img src="{$logo}" />{/if}
  <p>{$description}</p>

Can anyone help me what I am doing wrong? THX!!!

1条回答
老娘就宠你
2楼-- · 2019-08-18 01:42

You could modify your PHP code to ensure that $logo is set, e.g:

function hookFooter($params)
{
    global $smarty;
    $smarty->assign('ENT_QUOTES', ENT_QUOTES);
    if( file_exists('modules/ebbrandingfooter/logo-footer.jpg')){
        $smarty->assign('logo','modules/ebbrandingfooter/logo-footer.jpg');
    } else {
        $smarty->assign('logo', null);
    }
    $FOOTERdescription=Configuration::get('FOOTER_DESC');
    $smarty->assign('description',$FOOTERdescription );
    return $this->display(__FILE__, 'ebbrandingfooter.tpl');
}

Also note that after a } you don't need a semicolon.

查看更多
登录 后发表回答