2
我使用基于地址和GET方法的controll编码PHP,使用index.php?site = filename。然后我在内容div中包括现有的filename.php。那简直是有效的。此外,我已经得到通知DIV其中i包含数据的文件从数据库CodeIgniter网站框架
我试图得到类似的结果笨
html
head
/head
body
div notification bar (always on top like Material)
div menu (slide from left also like Material)
div content (depended on controller and loaded view)
div footer (only /body /html)
/body
/html
通过
public function __construct()
{
parent::__construct();
$this -> load -> view('notification ');
$this -> load -> view('menu ');
}
我想要做的,从模型发送数据通知视图,但我不能在构造函数中做到这一点。另外我不想在每个控制器的方法中加载相同的视图。我应该怎么做?我不提供现成的解决方案,但一些想法,也许伪代码?
或者也许这只是一个这样的解决方案?在每种方法中加载所有需要的视图?真?
class news extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this -> load -> view('header');
}
public function index()
{
[...]//data from model
$this -> load -> view('notification',$Data);
$this -> load -> view('menu',$Permission);
$this -> load -> view('news',$Content);
}
[...]
为什么不简单地创建一个包含视图的视图(有点像子视图)?这并不难,请参阅http://stackoverflow.com/questions/9402924/how-to-load-view-into-another-view-codeigniter-2-1 – SolarBear 2015-02-23 21:41:53
好的,谢谢,我会这样做,但它不能解决我在通知中的数据问题。一些通知将不活动,所以它们是如何设置的?或者我可以使用mysql查询来设置这个视图代码,但这是违反MWC规则的,是不是?你怎么想? – Bejkrools 2015-02-23 22:03:34