在Opencart中显示横幅日期明智

时间:2016-07-01 13:26:30

标签: opencart vqmod

我在opencart中制作一个opencart vqmod xml文件,其中会有粘性横幅粘贴到滚动条上,横幅将随日期变化而变化 1.Banner1表示当天:1-3-5-7-9 ---- 31 2.Banner2表示当天:2-4-6-8 ---- 30

它无法正常工作

为此:我创建了一个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>xyz@gmail.com</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>

1 个答案:

答案 0 :(得分: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 ...

}