使用日历和页面不显示下一年或上一年的日历

时间:2013-03-21 作者:code_rum

我创建了一个名为mysite的页面,并将永久链接设置为/XXX/wordpress/mysite‎

在此页面上,我正在创建日历。日历工作得很顺利。它适用于当前年份,但当单击“下一年”或“上一年”按钮时,一旦切换到下一年或上一年日历就会消失,并显示以下消息(未找到默认页面)“这有点尴尬,不是吗?”

它在默认permalink中工作正常,但在自定义结构permalink中工作不正常

日历是使用以下代码制作的

CSS:

<style type="text/css"> .body { 
font-family: Verdana; 
background-color : #ACACAC;; 
} 

.tr { 
background-color : #ACACAC; 
} 

.th { 
font-family: Verdana; 
} 

a.buttonbar:link, a.buttonbar:visited { 
font-size        : 9px; 
padding-top      : 1px; 
padding-bottom   : 1px; 
text-decoration  : none; 
background-color : #ACACAC; 
color            : #FFFFFF 
} 
a.buttonbar:hover { 
padding-top      : 1px; 
padding-bottom   : 1px; 
background-color : #CCCCCC; 
color            : #FFFFFF 
} 
.normal { 
font-family: Verdana; 
font-size: 8pt; 
color: #000000; 
} 
.today { 
font-family: Verdana; 
font-size: 8pt; 
font-weight:bold; 
color:#000066; 
background-color: #CACACA; 
} 
.weekend { 
font-family: Verdana; 
font-size: 8pt; 
color:#FF0000; 
} 
.selected { 
font-family: Verdana; 
font-size: 8pt; 
color: #FFFFFF; 
background-color: #C00000; 
} 
.event { 
font-family: Verdana; 
font-size: 8pt; 
color: #000000; 
background-color: #C6D1DC; 
} 
.head { 
color:#CCCCCC; 
font:Arial, Helvetica, sans-serif; 
font-size:12px; 
font-weight:500; 
background-color:#000066; 
} 
.title { 
color:#000066; 
font:Arial, Helvetica, sans-serif; 
font-size:12px; 
font-weight:bold; 
} 
.button { 
font-family      : Verdana, Arial, Helvetica, sans-serif; 
font-style       : normal; 
font-weight      : bold; 
font-size        : 10px; 
color            : #000000; 
background-color : #F0F0F0; 
border           : 1px solid #000066; 
}
</style>
脚本:

<script language="javascript"> 
function goLastMonth(month,year,form,field) 
{ 
    // If the month is January, decrement the year. 
    if(month == 1) 
{ 
--year; 
month = 13; 
}        
    document.location.href = \'http://localhost/wordpress/mysite/?month=\'+(month-1)+\'&year=\'+year; 
} 

function goNextMonth(month,year,form,field) 
{ 
    // If the month is December, increment the year. 
    if(month == 12) 
{ 
++year; 
month = 0; 
}    
    document.location.href = \'http://localhost/wordpress/mysite/?month=\'+(month+1)+\'&year=\'+year; 
} 
代码:

<?php 
$day = $_GET["day"];
$month = $_GET["month"];
$year = $_GET["year"];
if ($day == "")
$day = date("j");

if ($month == "")
$month = date("m");

if ($year == "")
$year = date("Y");

$currentTimeStamp = strtotime("$year-$month-$day");
$monthName = date("F", $currentTimeStamp);
$numDays = date("t", $currentTimeStamp);
$counter = 0;
?>
<body style="margin:0px 0px 0px 0px" class="body"> 
<table width=\'175\' border=\'0\' cellspacing=\'0\' cellpadding=\'0\' class="body"> 
<tr> 
    <td width=\'25\' colspan=\'1\'> 
    <input type=\'button\' class=\'button\' value=\' < \' onClick=\'<?php echo "goLastMonth($month,$year)"; ?>\'> 
    </td> 
    <td width=\'125\' align="center" colspan=\'5\'> 
    <span class=\'title\'><?php echo $monthName . " " . $year; ?></span><br> 
    </td> 
    <td width=\'25\' colspan=\'1\' align=\'right\'> 
    <input type=\'button\' class=\'button\' value=\' > \' onClick=\'<?php echo "goNextMonth($month,$year)"; ?>\'> 
    </td> 
</tr> 
<tr> 
    <td class=\'head\' align="center" width=\'25\'>S</td> 
    <td class=\'head\' align="center" width=\'25\'>M</td> 
    <td class=\'head\' align="center" width=\'25\'>T</td> 
    <td class=\'head\' align="center" width=\'25\'>W</td> 
    <td class=\'head\' align="center" width=\'25\'>T</td> 
    <td class=\'head\' align="center" width=\'25\'>F</td> 
    <td class=\'head\' align="center" width=\'25\'>S</td> 
</tr> 
<tr>
<?php 
for($i = 1; $i < $numDays+1; $i++, $counter++) 
{ 
    $timeStamp = strtotime("$year-$month-$i"); 
    if($i == 1) 
    { 
    // Workout when the first day of the month is 
    $firstDay = date("w", $timeStamp); 

    for($j = 0; $j < $firstDay; $j++, $counter++) 
    echo "<td> </td>"; 
    } 

    if($counter % 7 == 0) 
    echo "</tr><tr>"; 

    if(date("w", $timeStamp) == 0) 

    $class = "class=\'weekend\'"; 
    else 
    if($i == date("d") && $month == date("m") && $year == date("Y")) 
    $class = "class=\'today\'"; 
    else 
    $class = "class=\'normal\'"; 

    //echo "<td class=\'tr\' bgcolor=\'#ffffff\' align=\'center\' width=\'25\'><a class=\'buttonbar\' href=\'#\' onclick=\\"sendToForm(\'".sprintf("%02d/%02d/%04d", $month, $i, $year)."\',\'$field\',\'$form\');\\"><font $class>$i</font></a></td>"; 
    echo "<td class=\'tr\' bgcolor=\'#ffffff\' align=\'center\' width=\'25\'><a id=\'$i $month $year\' class=\'buttonbar\' target=\'_blank\' onmouseover=display($i,$month,$year) \\"><font $class>$i</font></a></td>";
} 
?> 
</tr> 
</table> 
</body> 

1 个回复
最合适的回答,由SO网友:code_rum 整理而成

我知道了。。。。我刚从一年改到一年,结果成功了:)不知道是什么问题:)

结束

相关推荐

jQuery UI & Admin (Calendar)

我是在吸快克烟还是这不管用?:/这一切似乎都很简单:function admin_head() { ?> <link type=\"text/css\" rel=\"stylesheet\" href=\"<?php bloginfo(\'template_url\'); ?>/css/jquery-ui-1.8.9.custom.css\" /> <script type=\"text/javascript\" src=\"