fuelphp - 找不到请求的视图:template.php

时间:2016-05-25 16:44:41

标签: php fuelphp

错误由以下方式触发:     C:/wamp/www/bayadko/fuel/core/classes/view.php @ line 440

这是我的index.php

<?php foreach ($parent as $parent): ?>
    <h3><?php echo Html::anchor('blog/view'.$parent->user_id, $parent->password) ?></h3>
    <p><?php echo $parent->password ?></p>
<?php endforeach; ?>

这是我的blog.php

<?php 
class Controller_Blog extends Controller_Base
{
  public function action_index() {
    $view = View::forge('blog/index');

    $view->parents = Model_Parent::find('all');

    $this->template->title = 'My Blog about Stuff';
    $this->template->content = $view;
  }
}
?>

可能导致此错误的原因是什么?

1 个答案:

答案 0 :(得分:0)

Controller_Base扩展了Controller_Template,它使用views文件夹中的template.php来为你模拟出fuelphp中的所有页面。这非常有用,因为它可以抽象出每个页面上包含的html或css等重要内容。要解决此问题,您只需在views文件夹中创建一个名为template.php的新文件。这里有一些入门代码可以帮助您开始使用template.php文件。

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo $title; ?></title>
    <?php echo Asset::css('bootstrap.css'); ?>
</head>
<body>
    <header>
        <div class="container">
            <?php echo $title; ?>
        </div>
    </header>
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <?php echo $content; ?>
            </div>
        </div>
        <hr/>
        <footer>
            <p class="pull-right">Page rendered in {exec_time}s using {mem_usage}mb of memory.</p>
            <p>
                <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.<br>
                <small>Version: <?php echo Fuel::VERSION; ?></small>
            </p>
        </footer>
    </div>
</body>
</html>
相关问题