PHP smarty variable error

徘徊边缘 提交于 2019-12-13 07:15:56

问题


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:


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.



来源:https://stackoverflow.com/questions/10075205/php-smarty-variable-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!