2012-04-18 9 views
6

Tôi đã bao gồm css theo quan điểm của tập tin như saucách đưa css theo quan điểm của tập tin

<link rel="stylesheet" type="text/css" href="<?php echo $this->baseUrl('style/root.css'); ?>" /> 
<link rel="stylesheet" type="text/css" href="<?php echo $this->baseUrl('style/reset.css'); ?>" /> 

Nhưng nó được đưa ra lỗi này ->

<b>Message:</b> Invalid controller specified (style) </p> 

trong application.ini, tôi đã sử dụng này

resources.frontController.baseUrl = "/zendtest/public" 
resources.view[] = ""; 

Làm cách nào để giải quyết vấn đề này?

Trả lời

14

trong bất kỳ tập tin view (.phtml mở rộng) sử dụng một cái gì đó như thế này cho javascript hoặc css:

$this->headScript()->prependFile('/scripts/jquery.min.js'); 
$this->headScript()->appendFile('/scripts/fg.menu.js'); 

$this->headLink()->appendStylesheet('/css/form.css'); 
$this->headLink()->prependStylesheet('/css/jquery_ui_theme/jquery-ui.custom.css'); 
+1

Nhưng cấu trúc thư mục cho tệp .css và .js là gì? Bạn nói '/ scripts/jquery.min.js' nhưng thư mục'/script' này nằm ở đâu? Điều nào là đúng nếu tôi sử dụng các mô-đun với ZF: 'Module/views/scripts/js' và' Module/views/scripts/css'? Hoặc 'Module/views/js' và' Module/views/css'? Cảm ơn bạn. – Green

+2

không, css & js đi vào/application/public/css và/application/public/js – max4ever

2

Đoạn mã bên dưới làm việc cho tôi, (tôi giả sử bạn có file css của bạn trong 'công cộng/css/bootstrp.css ') và dán dòng vào phần đầu của Chế độ xem của bạn.

<link href="<?php echo $this->baseUrl() . '/css/bootstrap.css'; ?>" media="all" rel="stylesheet" type="text/css" />