簡體   English   中英

Joomla網站:baseurl無法返回正確的url

[英]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>

它在這種頁面上工作良好:

http://mywebsite.com/index.php/myfolder

頁面“ myfolder”是類別中文章的列表。

當我單擊此頁面上的文章時,Joomla使用以下網址:

http://mywebsite.com/index.php/myfolder/article1

在這里,所有都不正確(css,js等),因為我的baseurl返回以下內容:

/夾

代替 :

/

而且我在index.php中包含的內容不適用於此頁面!

您已經遇到這個問題了嗎?

如何解決?

我沒有找到定義baseurl的地方,要糾正它,您能幫我嗎?

使用JURI::root()獲取Joomla的基本根

有關更多信息,請參見此處的 Joomla文檔頁面。 同樣, Joomla論壇帖子-在提及Joomla 1.6的早期RC時可能也會有所幫助。

好的,謝謝您的回答,但我認為您不能明確地知道僅包含文件夾的網址才有問題。

我通過在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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM