【问题标题】:smarty shows variable only if debug is acitvesmarty 仅在调试处于活动状态时才显示变量
【发布时间】:2015-03-16 19:46:05
【问题描述】:

我有以下 smarty 模板:

  <div class="col-md-4 col-sm-4 col-lg-4 col-xs-12 col-md-offset-4 col-lg-offset-4 col-sm-offset-4 login-box">
{$validation_errors}
    <p class="heading">Please Log In!</p>
    {form url='user/login'}
        <div class="form-group">
            <label for="Email">Email address</label>
            <input type="text" class="form-control" id="Email" placeholder="Enter email" name="email" />
        </div>
        <div class="form-group">
            <label for="Password">Email address</label>
            <input type="password" class="form-control" id="Password" placeholder="Enter password" name="password" />
        </div>
        <button type="submit" class="btn btn-success pull-right">Submit</button>
    {form}
</div>

这是分配$validation_errors的PHP代码:

$this->smartyci->assign('validation_errors', $error);

所以我现在的问题是,$validation_errors 只有在我将 smarty 设置为调试模式时才会显示在模板中:

<div class="col-md-4 col-sm-4 col-lg-4 col-xs-12 col-md-offset-4 col-lg-offset-4 col-sm-offset-4 login-box">
{debug}
{$validation_errors}
    <p class="heading">Please Log In!</p>
    {form url='user/login'}
        <div class="form-group">
            <label for="Email">Email address</label>
            <input type="text" class="form-control" id="Email" placeholder="Enter email" name="email" />
        </div>
        <div class="form-group">
            <label for="Password">Email address</label>
            <input type="password" class="form-control" id="Password" placeholder="Enter password" name="password" />
        </div>
        <button type="submit" class="btn btn-success pull-right">Submit</button>
    {form}
</div>

我现在真的知道为什么只有在我将 {debug} 放入模板时才会显示该变量。顺便说一句,任何其他变量都可以正常工作。

【问题讨论】:

  • $this->smartyci->assign('validation_errors', $error); - $this-smartyci 有错吗???
  • 没有 $this->smartyci 没问题 :)

标签: php codeigniter debugging smarty


【解决方案1】:

$validation_errors 变量不知何故受到 smarty 缓存的影响。 我已禁用 chaching,现在一切正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-08
    • 2016-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-10
    相关资源
    最近更新 更多