CakePHP 主题?
我尝试创建一个基于主题的 CakePHP 应用程序。我使用最新版本 CakePHP 2.0.0
我的应用程序由文件
/app/Controller/AppController.php
class AppController extends Controller
{
public $helpers = array('Html', 'Session', 'Form');
public function beforeFilter()
{
$this->setupTheme();
}
private function setupTheme()
{
$this->viewClass = 'Theme';
$this->theme = 'Mars';
$this->layout = 'admin';
}
}
/app/Controller/LanguagesController.php
class LanguagesController extends AppController
{
public $name = "Languages";
public function index()
{}
}
/app/View/Themed/Mars/Languages/index.php
// Currently Empty
/app/View/ 组成Themed/Mars/Layouts/admin.ctp
<?php echo $this->Html->docType('xhtml-strict'); ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php echo $this->Html->charset(); ?>
<meta name="author" content="Nikos Merianos" />
<title><?php echo $title_for_layout; ?></title>
<?php
echo $this->Html->meta('icon');
echo $this->Html->css('amdin.css');
?>
</head>
<body>
<?php
echo $this->Session->flash();
echo $content_for_layout;
echo $this->element('sql_dump');
echo $scripts_for_layout;
?>
</body>
</html>
/app/View/Themed/Mars/webroot/css/admin.css
body
{
background: #FA0;
}
我现在的问题
为什么代码进入 Layout 文件夹下的 admin.ctp 第 11 行(echo $this->Html->css('amdin.css');) 返回以下结果:
<link rel="stylesheet" type="text/css" href="/mars/css/amdin.css" />
问题是链接不正确。 CSS 文件未加载,因为该路径中不存在该文件。有什么想法吗?
I try to create a CakePHP application based on themes. I using the latest version CakePHP 2.0.0
My application consists from that files
/app/Controller/AppController.php
class AppController extends Controller
{
public $helpers = array('Html', 'Session', 'Form');
public function beforeFilter()
{
$this->setupTheme();
}
private function setupTheme()
{
$this->viewClass = 'Theme';
$this->theme = 'Mars';
$this->layout = 'admin';
}
}
/app/Controller/LanguagesController.php
class LanguagesController extends AppController
{
public $name = "Languages";
public function index()
{}
}
/app/View/Themed/Mars/Languages/index.php
// Currently Empty
/app/View/Themed/Mars/Layouts/admin.ctp
<?php echo $this->Html->docType('xhtml-strict'); ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php echo $this->Html->charset(); ?>
<meta name="author" content="Nikos Merianos" />
<title><?php echo $title_for_layout; ?></title>
<?php
echo $this->Html->meta('icon');
echo $this->Html->css('amdin.css');
?>
</head>
<body>
<?php
echo $this->Session->flash();
echo $content_for_layout;
echo $this->element('sql_dump');
echo $scripts_for_layout;
?>
</body>
</html>
/app/View/Themed/Mars/webroot/css/admin.css
body
{
background: #FA0;
}
My problem now
Why the code into admin.ctp under Layout folder in line 11 (echo $this->Html->css('amdin.css');) return the following result :
<link rel="stylesheet" type="text/css" href="/mars/css/amdin.css" />
The problem is that link is incorect. The CSS file is not loaded because does not exists into that path. Any idea please ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查你的拼写...
当您包含 CSS 文件时,“admin”中的字母被调换了...
Check your spelling...
You have letters in 'admin' transposed when you include your CSS file...
admin 应该是 admin,而不是 amdin
编辑:就像 Farray 所说。
admin should be admin, not amdin
Edit: like Farray said.