2015-10-06 60 views
0

我的网址是:如何在codeigniter中呈现视图时传递数据或数据数组?

http://localhost/CodeIgniterCms/admin/dashboard/otherpages/123 其中,

笨CMS

- admin 

-- dashboard (the controller) 

--- otherpages (Method) 

控制器代码

public function otherpages($somedata) { 
    $this->render('admin/second_view',$somedata); 
} 

守则second_view.php

<pre> 
    <div class="container"> 
    <?php echo $somedata;?> 
    </div> 
</pre> 

但它抛出错误
无法加载所需的文件:你otherpages函数内部管理/ 123.php

+0

你有什么特别的路由?因为默认是'localhost/class/function/data /',你的url不完全对应它。 – Wold

+0

是的,我使用.htaccess删除了index.php,并通过在route.php中声明route config来路由我的管理应用程序和公共应用程序。 –

+1

您能否包含相关的路由信息​​?这将有助于回答这个问题。 – Wold

回答

0

试试这个:

$data['somedata'] = $somedata; <br/> 
$this->load->view('admin/second_view',$data); 
+0

我的代码是$ this-> render('admin/second_view',$ somedata);'
实际上我在应用程序/内核中有一个MY_Controller,它为我加载master_header和master_footer的渲染模板。我正在嵌入链接,我只是根据那个创建了我的应用程序。
{link}(http://avenir.ro/create-cms-using-codeigniter-3/) –

相关问题