我使用Html Helper css()
方法將我的樣式就像這樣:<?php echo $this->Html->css('reset.css');?>
但如果我的CakePHP的應用程序是通過比http://site.domain.com
以外的路徑訪問,即http://site.domain.com/my_app
如何在cakephp中獲得基礎Url?
什麼是鏈接我的樣式表最好的命令?
我使用Html Helper css()
方法將我的樣式就像這樣:<?php echo $this->Html->css('reset.css');?>
但如果我的CakePHP的應用程序是通過比http://site.domain.com
以外的路徑訪問,即http://site.domain.com/my_app
如何在cakephp中獲得基礎Url?
什麼是鏈接我的樣式表最好的命令?
完全相同的命令應該工作:
<?php
echo $this->Html->css('reset.css');
?>
給出的路徑'reset.css'
不以斜線開始它會自動添加路徑的CSS文件夾中。
順便說一句,如果你需要得到基本URL的蛋糕,你可以使用Router
類:
//with http://site.domain.com/my_app
echo Router::url('/') //-> /my_app
echo Router::url('/', true) //-> http://site.domain.com/my_app
有幾種不同的方式來獲得基本路徑。 我使用
echo $this->webroot; //Note: auto appends trailing slash
如果這僅返回/而不是/應用/ Webroot公司的網址是什麼? – mtpultz
在相關說明。
如果您需要的主題,網址,你可以這樣做:
$this->webroot.'theme/'.$this->theme
用這個的BaseURL
echo $this->html->url('/', true);
在這裏找到答案http://stackoverflow.com/a/13660262/1868660 –