2014-09-24 75 views
0

我有這個roate.php的問題。(Datalife引擎)PHP隨機圖像旋轉圖片不顯示

我做了一切像這裏描述的那樣 PHP Random Image Rotation 但是有圖片顯示。 這就是我的代碼的樣子。

的style.css

.header_img { 
overflow: hidden; 
width: 1010px; 
margin: 0 auto; 
height: 276px; 
background: url(../header/rotate.php) no-repeat center 0; 
border-width: 0 1px; 

main.tpl

<!-- /header --> 
</header> 
<div id="header_img"> 
    <div class="header_img"><!-- no text --></div> 
</div> 

我是初學者,這是所有新me.So我希望有人能幫助我在這裏。

問候

+0

打開'rotate.php'和檢查如果PHP正確呈現圖像。 – Scony 2014-09-24 16:32:49

回答

2

你的問題是不是雙方rotate.php和DLE劇本的問題,但它的問題在哪裏放置「rotate.php」文件的位置,你不能放置任何PHP文件你主題文件夾,它會被腳本和htaccess阻止,所以解決方案很簡單,在「模板」文件夾之外的根目錄下創建新文件夾,例如:「header」或「background」

然後放置所有圖像並旋轉.php文件夾內,所以你可以訪問文件夾和圖像像

http://your-domain.com/header/rotate.php 
http://your-domain.com/header/image-1.php 
http://your-domain.com/header/image-2.php 
... 
or 
--- 
http://your-domain.com/background/rotate.php 
http://your-domain.com/background/image-1.php 
http://your-domain.com/background/image-2.php 

你main.tpl應該是這樣的

<style type="text/css"> 
.header_img { 
overflow: hidden; 
width: 1010px; 
margin: 0 auto; 
height: 276px; 
background: url(/header/rotate.php) no-repeat center 0; 
/* or */ 
/* 
background: url(/background/rotate.php) no-repeat center 0; 
*/ 
border-width: 0 1px; 
</style> 
    <!-- /header --> 
</header> 
<div id="header_img"> 
    <div class="header_img"><!-- no text --></div> 
</div> 

從「模板」文件夾中保留所有的PHP文件了。並且不要將css放在任何css文件中,將所有代碼放在main.tpl中。

或者您可以使用這種技術,我們在我們沒有爲他們設計的

1)下載rotator.txt從A List Apart一些網站使用,將其重命名rotator.php。

2)將圖像旋轉到與rotator.php相同的目錄中。

3)通過FTP上傳所有文件。

4)main.tpl在瀏覽器中添加該代碼

<style type="text/css"> 
#rotator{ 
overflow: hidden; 
width: 1010px; 
margin: 0 auto; 
height: 276px; 
background: url(/background/rotate.php) no-repeat center 0; 
border-width: 0 1px; 
</style> 
    <!-- /header --> 
</header> 
<div id="rotator">&nbsp;</div> 
+0

DLE有一些PHP文件放置在模板文件夾中的問題,這必須是rorate.php不工作的原因 – 2014-09-25 15:35:28