[英]Joomla site : baseurl does not return correct url
我使用Joomla 2.5.7,在一頁中遇到$ this-> baseurl問題。
在我的index.php文件,我unclude .js文件,並與baseURL時 .css文件就像這個例子:
<script src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/jquery-1.2.6.min.js" type="text/javascript"></script>
它在這種頁面上工作良好:
頁面“ myfolder”是類別中文章的列表。
當我單擊此頁面上的文章時,Joomla使用以下網址:
在這里,所有都不正確(css,js等),因為我的baseurl返回以下內容:
/夾
代替 :
/
而且我在index.php中包含的內容不適用於此頁面!
您已經遇到這個問題了嗎?
如何解決?
我沒有找到定義baseurl的地方,要糾正它,您能幫我嗎?
好的,謝謝您的回答,但我認為您不能明確地知道僅包含文件夾的網址才有問題。
我通過在configuration.php中使用live_site變量找到了解決方案。
首先,您需要在腳本頂部構建此功能
function thisSite($a){
$this_raw = parse_url($a);
$b = preg_replace('#^www\.(.+\.)#i', '$1', $this_raw['host']);
return $b; }
然后您以這種方式使用該功能
$thisSite = JURI::root();
// $thisSite will echo http://www.mywebsite.com/
$thisSite_base = thisSite($thisSite);
// the function removes http:// and the www and the /path
echo $thisSite_base;
這會回聲
mywebsite.com
在模板中,可以使用$this->baseurl
快捷方式代替JURI::base( true )
。
我還沒有測試這些,但是也許嘗試其中之一:
JDocument::base
JDocument::baseurl
JURI::base()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.