dphnn333971 2013-09-05 23:56
浏览 114
已采纳

PHP与命名空间和Smarty错误:未知标签“循环”

Everyone!

I'm working with PHP and Smarty in my project. I'm using namespaces and I'm having a problem when I call Smarty functions, for sample cycle

I'm having this error: Syntax Error in template ".\sys\adm\template\fields\inputFileField.tpl" on line 23 "{cycle values="um,dois"}" unknown tag "cycle"

I'm using spl_autoload_register to auto load classes in project:

function smartyAutoloader($className) {
    $file = "sys/classes/smarty/$className.class.php";

    if (file_exists($file)) {
        require $file;
        return true;
    }

    return false;
}

I did not change the namespace in Smarty class, so I'm importing Smarty this way:

use \Smarty;

If I comment the cycle code, my code works correctly.

Follow is the problemmatic code:

{for $x = 0 to 10}
    {cycle values="um,dois"} {*line 23 on inputFileField.tpl*}
{/for}

I'm not knowing to use namespace and Smarty in same project. I'm sure this error is because of namespaces. Can someone help me?

Thanks in advance

  • 写回答

2条回答 默认 最新

  • doy51723 2014-10-31 19:13
    关注

    I found this post at the Smarty forum

    The problem seems to be a wrong or relative path to the plugin folder. After setting the path to the plugin folder absolut, it works fine, even with namespaces.

    Have also a look at the Smarty documentation:

    Technical Note

    For best performance, do not setup your $plugins_dir to have to use the PHP include path. Use an absolute pathname, or a path relative to SMARTY_DIR or the current working directory.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度