用户
 找回密码
 入住 CI 中国社区
搜索
查看: 4151|回复: 2
收起左侧

KHN自带例子中的viewinview例子无法执行..

[复制链接]
发表于 2008-3-23 13:41:59 | 显示全部楼层 |阅读模式
http://xxx/index.php/examples/template
出错提示:
KHN2.1.1完全版中带来的例子,config.php已改

Runtime MessageAn error was detected which prevented the loading of this page. Ifthis problem persists, please contact the website administrator.
Undefined property:  Examples_Controller:load
Error occurred at line 5 of F:/easeyoo/KHN211All/application/views/viewinview/container.php.
Stack Trace
  • system\libraries\Controller.php [69]:include( application\views\viewinview\container.php )
  • system\libraries\View.php [188]:Controller_Core->_kohana_load_view( F:/easeyoo/KHN211All/application/views/viewinview/container.php, Array
    (
        [title] => View-in-View Example
        [content] => This is my view-in-view page content.
        [copyright] => © 2007 Kohana Team
        [header] => View Object
            (
                [kohana_filename:protected] => F:/easeyoo/KHN211All/application/views/viewinview/header.php
                [kohana_filetype:protected] => .php
                [data:protected] => Array
                    (
                        [title] => View-in-View Example
                        [content] => This is my view-in-view page content.
                        [copyright] => © 2007 Kohana Team
                    )

            )

    )
    )
  • application\controllers\examples.php [76]:View_Core->render( 1 )
  • system\core\Kohana.php [268]:Examples_Controller->template(  )
  • Kohana::instance(  )
  • system\core\Event.php [217]:call_user_func( Array
    (
        [0] => Kohana
        [1] => instance
    )
    )
  • system\core\Bootstrap.php [55]:Event::run( system.execute )
  • index.php [83]:require( system\core\Bootstrap.php )
Loaded in 0.0891 seconds, using 0.85MB of memory. Generated by Kohana v2.1.1.
 楼主| 发表于 2008-3-23 13:42:50 | 显示全部楼层
出错提示的是一个view页面里的:
<?php
$this->load->view("....")
?>
语句..
发表于 2008-3-23 22:00:58 | 显示全部楼层
$this->load() 的用法已经被取消了。

我测试了一下,需要做如下修改:

在 controllers/examples.php 里,将:

PHP复制代码
$view = $this->load->view('viewinview/container', $data);
$view->header = $this->load->view('viewinview/header', $data);
复制代码


修改为:

PHP复制代码
$view = new View('viewinview/container', $data);
$view->header = new View('viewinview/header', $data);
复制代码


在 views/viewinview/container.php 里,将最后一行修改为:

PHP复制代码
<?php echo new View('viewinview/footer', array('copyright' => $copyright )) ?>
复制代码


要注意的是,$this->load() 的用法已经被取消,所以你装在libraries和helpers时,也统一用标准的PHP语法(即,new Class())。

本版积分规则