2
在我的CodeIgniter應用程序中有一個共同的頁眉和頁腳視圖,這些視圖包含在不同的視圖中。我header_view
很簡單,只要:僅在特定視圖中包含js和css文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?php echo $page_title;?></title>
<link rel="stylesheet" href="<?php echo base_url();?>/css/master.css" type="text/css" media="screen" />
<script src="<?php echo base_url();?>js/common.js" type="text/javascript"></script>
</head>
<body>
<!-- end of header -->
現在讓我們假設我有一個名爲form_view
,在這裏我想包括CSS文件form.css
和JavaScript文件form.js
另一種看法。由於這些文件僅用於form_view,我不想將它們添加到header_view中,因爲它們將包含在我的應用程序中的所有視圖中。
所以我的問題仍然存在,如何在特定的視圖中包含特定的CSS或特定的JavaScript文件時,使用上面的常見標題。
謝謝。
我不確定整個頁面是否使用單個視圖是一個好主意。我會將標題,正文,頁腳中的視圖分開...因此,在表單控制器中,您可以加載不同的標題。 –
我在上面提到過,我有一個共同的header_view和footer_view,它包含在所有視圖中。例如,我將在form_view和其他視圖中包含相同的header_view和footer_view。 – Roman
您使用模板庫還是CI默認的:http://codeigniter.com/user_guide/general/views.html?我想了解你是如何在所有視圖中包含標題的...... –