2012-05-10 44 views
0

我創建了一個包含指向其他頁面的鏈接的塊。該塊位於所有頁面的頁腳中。Drupal 6塊中的相對鏈接

<a href="terms_and_conditions">Terms and Conditions</a> 

這個工程上的網址的頁面罰款...

http://mywebs.localhost/site1/page1 

的鏈接是否正確地解析爲:

http://mywebs.localhost/site1/terms_and_conditions 

(其中 '第1頁' 是在「URL的值路徑設置'即使用'路徑'模塊爲/ node/56創建別名)

但是當我去到一個頁面是pa該模塊的Ubercart的RT ...

http://mywebs.localhost/site1/cart/checkout 

塊中的鏈接錯誤地解析爲...

http://mywebs.localhost/site1/cart/terms_and_conditions 

很顯然,我可以得到,如果我使用完整的絕對鏈接它的工作,但我想當我上傳到遠程主機時無需更改所有內容即可工作。

關於相對路徑有相當多的文檔和問題。但據我所知,它可以處理頁面內容部分的鏈接。任何人都可以請我指出正確的方向。

回答

0

您應該使用url()功能或$base_url生成的鏈接

<a href="<?php echo url('terms_and_conditions'); ?>">Terms and Conditions</a> 

<a href="<?php global $base_url; echo $base_url; ?>/terms_and_conditions">Terms and Conditions</a> 
+2

謝謝。萬一有其他人有這個問題,你必須啓用'PHP過濾器'模塊。在塊中輸入文本時,將「輸入格式」設置爲「PHP代碼」。您可能還必須調整您的用戶權限。 – spiderplant0

2

爲什麼不<a href="/terms_and_conditions">Terms and Conditions</a>?嘗試在你的路徑之前放置斜線。

剛剛看了評論,對不起,我看其他的方式與允許PHP輸入
<?php print l('Terms and Conditions', 'terms_and_conditions'); ?>

但是,沒有PHP輸入您可以使用http://drupal.org/project/shortcode,它允許與URL轉換令牌一個完整的鏈接,如在WordPress中。

+0

只要您沒有計劃將您的網站託管在子文件夾中,這就是最好的辦法。 –

+0

尾部斜線美麗,快速,非侵入性和工作!謝謝 –