且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

destoon栏目首页加页码

更新时间:2022-07-02 16:36:27

看到一个网站上一个栏目首页上显示的可以有页面,但是使用destoon上首页的模板上是没有页码的,而列表页是有页面的,那么如果使用首页才能有页面


要想让信息产生分页,的必要条件是在写tags时要加入showpage=1&pagesize=?这样的参数,然后再在template中指定一个模板,这个模板要放在tag文件夹中,并且里边要加入

{if $showpage && $pages}<div class="pages">{$pages}</div>{/if}这样的参数



想要实现  不指定分类的话,默认显示这个频道的所有分类的消息,并且分页码,

要想实现这些目标,需要调整一下频道下index.php,index.php中包含的是module中的index.inc.php如果我们想让首页显示页码,需要包含list.inc.php,但是list.inc.php是不是能拿过来就用的,需要改造一下,

需要修改的地方,

生成页码的函数listpages,***从新生成一个新的函数,专门用来生成首页的页码

$pages = listpages_idx($CAT, $items, $page, $pagesize);


function listpages_idx($CAT, $total, $page = 1, $perpage = 20, $step = 2) {
	global $DT, $MOD, $L;
	if($total <= $perpage) return '';
	$items = $total;
	$total = ceil($total/$perpage);
	if($page < 1 || $page > $total) $page = 1;
	$home_url = $MOD['linkurl'].$CAT['linkurl'];
	$demo_url = $MOD['linkurl'].listurl($CAT, '{destoon_page}');
	$demo_url = "index.php?page={destoon_page}";
	//echo "home_url={$home_url} and demo_url={$demo_url}";

	$pages = '';
	include DT_ROOT.'/api/pages.'.($DT['pages_mode'] ? 'sample' : 'default').'.php';
	return $pages;
}

if ($MOD['cat_property'] && $CAT['property'])
{
    require DT_ROOT . '/include/property.func.php';
    $PPT = property_condition($catid);
}
unset($CAT['moduleid']);
<span style="color:#ff0000;">
$maincat = get_maincat(0, $moduleid);
// $condition = "groupid>5 and catids like '%,".$catid.",%'";
$condition=" status=3 ";
// echo "condition=".$condition;</span>



if ($cityid)
{
    $areaid = $cityid;
    $ARE = $AREA[$cityid];
    $condition .= $ARE['child'] ? " AND areaid IN (" . $ARE['arrchildid'] . ")" : " AND areaid=$areaid";
    $items = $db->count($table, $condition, $CFG['db_expires']);
}
else
{

       <span style="color:#ff0000;"> $items = $db->count($table, $condition, $CFG['db_expires']);
         $CAT['item'] = $items;</span>
}


以上标红的地方,就可以,大家可以试一下




有页面,必须有信息的长度,页面的大小,才能页面,而destoon的首页是循环列出所的的栏目,并列出栏目下的几个文章,所以不会使用原来的模板是不会出现页面的,因为首页的重点在于所有的分类列出,不在于列出所有信息,如果你对栏目感兴趣再点过去,查看列表,所以要想有页面,必须指定一个栏目ID,不然会出现404错误,

destoon每个频道的$moduleid都是规定在每个频道下的config.inc.php

每个栏目的ID号是以url参数形式传递到程序中的,catid

同样道理我们可以把list.php拷贝一份做为index.php,并在第一行上规定好$catid,这样就达到了加入页码的目的