CodeIgniter 中国开发者社区诚征热爱 CI 的版主

查看完整版本: KHN自带例子中的viewinview例子无法执行..

iptton 2008-3-23 13:41

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

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 [b]line 5[/b] of [b]F:/easeyoo/KHN211All/application/views/viewinview/container.php[/b].
Stack Trace[list][*][b]system\libraries\Controller.php [69]:[/b]include( application\views\viewinview\container.php )[*][b]system\libraries\View.php [188]:[/b]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
                )

        )

)
)[*][b]application\controllers\examples.php [76]:[/b]View_Core->render( 1 )[*][b]system\core\Kohana.php [268]:[/b]Examples_Controller->template(  )[*]Kohana::instance(  )[*][b]system\core\Event.php [217]:[/b]call_user_func( Array
(
    [0] => Kohana
    [1] => instance
)
)[*][b]system\core\Bootstrap.php [55]:[/b]Event::run( system.execute )[*][b]index.php [83]:[/b]require( system\core\Bootstrap.php )[/list]Loaded in 0.0891 seconds, using 0.85MB of memory. Generated by Kohana v2.1.1.

iptton 2008-3-23 13:42

出错提示的是一个view页面里的:
<?php
$this->load->view("....")
?>
语句..

沧蓝 2008-3-23 22:00

$this->load() 的用法已经被取消了。

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

在 controllers/examples.php 里,将:

[code=PHP]$view = $this->load->view('viewinview/container', $data);
$view->header = $this->load->view('viewinview/header', $data);[/code]

修改为:

[code=PHP]$view = new View('viewinview/container', $data);
$view->header = new View('viewinview/header', $data);[/code]

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

[code=PHP]<?php echo new View('viewinview/footer', array('copyright' => $copyright )) ?>[/code]

要注意的是,$this->load() 的用法已经被取消,所以你装在libraries和helpers时,也统一用标准的PHP语法(即,new Class())。
页: [1]
查看完整版本: KHN自带例子中的viewinview例子无法执行..