某些情況下,我們需要調(diào)用昨天發(fā)布、兩天前發(fā)布、某個(gè)時(shí)間段發(fā)布的文章,而織夢默認(rèn)的只能夠調(diào)過去X天內(nèi)發(fā)布的文章,那么該如何解決這個(gè)問題呢?
打開 /include/taglib/arclist.lib.php 文件
找到:
-
//時(shí)間限制(用于調(diào)用最近熱門文章、熱門評論之類),這里的時(shí)間只能計(jì)算到天,否則緩存功能將無效
-
if($subday > 0)
-
{
-
$ntime = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y'));
-
$limitday = $ntime - ($subday * 24 * 3600);
-
$orwheres[] = " arc.senddate > $limitday ";
-
}
修改為:
-
//時(shí)間限制(用于調(diào)用最近熱門文章、熱門評論之類),這里的時(shí)間只能計(jì)算到天,否則緩存功能將無效
-
//當(dāng)subday=1的時(shí)候調(diào)用1天內(nèi)的文章
-
//當(dāng)subday=2的時(shí)候調(diào)用昨天的文章
-
//當(dāng)subday=3的時(shí)候調(diào)用2天前得所有文章
-
//當(dāng)subday=7的時(shí)候調(diào)用7天內(nèi)得所有文章
-
if($subday > 0)
-
{
-
if($subday == 1)
-
{
-
$ntime = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y'));
-
$limitday = $ntime - ($subday * 24 * 3600);
-
$orwheres[] = " arc.senddate > $limitday ";
-
}
-
else if ($subday == 2)
-
{
-
$ntime = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y'));
-
$limitday = $ntime - ($subday * 24 * 3600);
-
$lomitday = $ntime;
-
$orwheres[] = " arc.senddate < $lomitday && arc.senddate > $limitday";
-
}
-
else if ($subday == 3)
-
{
-
$ntime = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y'));
-
$limitday = $ntime -($subday * 24 * 3600)+(1*24 * 3600);
-
$orwheres[] = " arc.senddate < $limitday ";
-
}
-
else if ($subday == 7)
-
{
-
$ntime = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y'));
-
$limitday = $ntime - ($subday * 24 * 3600);
-
$orwheres[] = " arc.senddate > $limitday ";
-
}
-
}
調(diào)用方法:
-
{dede:arclist row=10 titlelen=32 subday='1'}
-
<li><a href="[field:arcurl/]">[field:title/]</a></li>
-
{/dede:arclist}
//當(dāng)subday=1的時(shí)候調(diào)用1天內(nèi)的文章
//當(dāng)subday=2的時(shí)候調(diào)用昨天的文章
//當(dāng)subday=3的時(shí)候調(diào)用2天前得所有文章
//當(dāng)subday=7的時(shí)候調(diào)用7天內(nèi)得所有文章