2016-07-01 25 views
0

我在opencart中製作opencart vqmod xml文件,其中粘滯橫幅將粘貼到滾動條,橫幅將隨日期明智更改 1.Banner1在第1-3-5-7天顯示-9 ---- 31 2.Banner2顯示一天:2-4-6-8 ---- 30顯示橫幅日期在Opencart中明智

它不工作預計

要做到這一點:我創建了一個XML文件

<?xml version="1.0" encoding="utf-8"?> 
<modification> 
    <id>Banner Rotate</id> 
    <version>2.2 and 2.1 </version> 
    <vqmver required="true">2.4.0</vqmver> 
    <author>[email protected]</author> 


    <file path="catalog/view/theme/*/template/common/header.tpl"> 
     <operation> 
      <search position="after"><![CDATA[<body>]]></search> 
      <add><![CDATA[ 
<div id="slideout"><a href="http://line.me/ti/p/~dynamic09" target="_blank"> 
    <img src="/catalog/view/theme/fashionstore/img/line.jpg" alt="line" /> 
    <div id="slideout_inner"> 
$today = getdate(); 
$day = $today['wday']; 
if ($day == 1 OR $day == 3 OR $day == 5 OR $day == 7 OR $day == 9 OR $day == 11 OR $day == 13 OR $day == 15 OR $day == 17 OR $day == 19 OR $day == 21 OR $day == 23 OR $day == 25 OR $day == 27 OR $day == 29 OR $day == 31){ 
    echo " <img src="/catalog/view/theme/fashionstore/img/line_banner1.jpg" alt="banner1" /> 
'>"; 
} 
elseif (

$day == 2 OR $day == 4 OR $day == 6 OR $day == 8 OR $day == 10 OR $day == 12 OR $day == 14 OR $day == 16 OR $day == 18 OR $day == 20 OR $day == 22 OR $day == 24 OR $day == 26 OR $day == 28 OR $day == 30 OR 

){ 
    echo "<img src=' <img src="/catalog/view/theme/fashionstore/img/line_banner2.jpg" alt="banner2" /> 
' />"; 
} 
else { echo <img src="/catalog/view/theme/fashionstore/img/line.jpg" alt="line" /> 
;} 
    </div> 
</a> 
</div> 

     ]]></add> 
     </operation> 
    </file> 
</modification> 

回答

0

您正在使用wday獲得一週的日期1- 7你需要mday 1-31從getdate()陣列得到一天,你也可以檢查一天是偶數還是偶數

$today = getdate(); 
$day = $today['mday']; // must be mday to get the current day 

if ($day % 2 != 0) { // odd 1 3 5 7 ... 

} else { // even 2 4 6 8 ... 

}