【问题标题】:smarty not working in codeignitersmarty 不能在 codeigniter 中工作
【发布时间】:2015-06-15 01:50:30
【问题描述】:

我在 Codeigniter 中安装了 Smarty,但它并没有真正工作。这是我所做的:

  1. 我按照以下说明操作:

    http://sunwebexpert.com/books/detail/PHP/integrating-smarty-and-codeigniter.html

但我还在库中放了另一个文件:parser.php,这是一个用于解析的库(我之前用 smarty 使用过,效果很好)

  1. Codeigniter 的 autoload.php 上写道:

    $autoload['libraries'] = array('parser','smarty');
    
  2. 在主控制器上我写了这个函数来测试:

    public function index()
    {
      $this->data['d'] = 2;
      $this->parser->parse('base/test.tpl', $this->data);
    }
    

但结果是没有错误显示,我看到了模板中写的变量“d”:

{$d}

所以我有两个问题:

  1. 如果我像以前在其他项目中那样安装 smarty,为什么我看不到变量值?

  2. 如果有错误,如何启用查看?

【问题讨论】:

  • 答案 2:在 CoideIgniter 的根文件夹中,打开 index.php 文件并在第 21 行附近设置 define('ENVIRONMENT', 'development');。这将使您能够显示任何错误、警告、通知消息。

标签: codeigniter parsing templates smarty


【解决方案1】:

问题在于,在 codeigniter 中,有一个名为 Parser 的内置库。这就是为什么这可能会导致与您的库名称发生冲突的原因。尝试重命名您的库名称或使用内置库。

Here 是如何在 codeigniter 上显示错误。

希望对你有用。

【讨论】:

  • 谢谢。昨天我可以在朋友的帮助下解决这个问题,这就是问题所在。我正在使用另一个 Parser 类,而不是 codeigniter 的。
猜你喜欢
  • 1970-01-01
  • 2016-05-09
  • 2015-03-04
  • 1970-01-01
  • 2015-08-11
  • 1970-01-01
  • 1970-01-01
  • 2023-03-22
  • 1970-01-01
相关资源
最近更新 更多