织梦列表页点击按价格按评分按更新按点击排序进行筛选方法

2021-06-21 作者:未知   |   浏览(
倘若网站中,有一个价格字段trueprice,我期望依据价格从小到大,或从大到小进行点击筛选,或按热点,最新产品进行排序,成效图如下
]

29unset;//删除一个字段

30//删除数组中的个别元素,活动状况,进行中,刚结束等,这部分值是依据结束时间动态判断的,所以,数据库中并没有,需要过滤掉这个sql查看条件

31foreach {

32//过滤掉不在$addtable表格中的字段,本次不负责处置

33//print_r;exit;

34$filtersql .= ? AND $addtable..snail_filter. = .snail_filter). : ;

35}

36}

37}

38else

39{

40$addField = ;

41$addJoin = ;

42}

010$uah3age=页;

三,替换函数function GetArcList为全新的

001function GetArcList

003{

004global $cfg_list_son;

005$typeid=$this-TypeID;

006if $row = 10;

007if $limitstart = 0;

008if $titlelen = 100;

009if $infolen = 250;

010if $imgwidth = 120;

011if $imgheight = 120;

012if $listtype = all;

013if $orderWay = desc;

014if {

015$orderby=default;

016}

017else {

018$orderby=strtolower;

019}

020$tablewidth = str_replace;

021if $tablewidth=100;

022if $col=1;

023$colWidth = ceil;

024$tablewidth = $tablewidth.%;

025$colWidth = $colWidth.%;

026$innertext = trim;

027if {

028$innertext = GetSysTemplets;

029}

225//编译附加表里的数据

226foreach

227{

228$row[strtolower] = $v;

229}

230foreach

231{

232if)

233{

234$row[$k] = $this-ChannelUnit-MakeField;

235}

236}

237if)

238{

239foreach

240{

44//统计数据库记录

241//h3rint_r;exit;所有字段名

242if==array)

243{

244//传递整个数组,在runphp模式中有特殊用途

245$this-dtp2-Assign;

246}

247else

248{

249if]))

250{

251$this-dtp2-Assign]);

252}

253else

254{

255$this-dtp2-Assign;

256}

257}

258}

259}

260if{

009$ualasth3age=末页;

2a class=ib h3adding-right href=/h3lus/list.h3hh3?tid={dede:field.tyh3eid/}myorder=new{dede:h3hh3}if{echo sh3an最新/sh3an;}else{echo 最新;}{/dede:h3hh3}/a

187//处置一些特殊字段

188$row[infos] = cn_substr;

189$row[id] = $row[id];

190if

191{

192$row[arcrank] = $row[corank];

193}

194$row[filename] = $row[arcurl] = GetFileUrl;

196$row[typeurl] = GetTypeUrl,$row[isdefault],$row[defaultname],

197$row[ispart],$row[namerule2],$row[moresite],$row[siteurl],$row[sitepath]);

198if

199{

200$row[litpic] = $GLOBALS[cfg_cmspath]./images/defaultpic.gif;

201}

202if $GLOBALS[cfg_multi_site] == Y)

203{

204$row[litpic] = $GLOBALS[cfg_mainsite].$row[litpic];

205}

206$row[picname] = $row[litpic];

207$row[stime] = GetDateMK;

208$row[typelink] = a href=.$row[typeurl]..$row[typename]./a;

209$row[image] = img src=.$row[picname]. border=0 width=$imgwidth height=$imgheight alt=.ereg_replace.;

210$row[imglink] = a href=.$row[filename]..$row[image]./a;

211$row[fulltitle] = $row[title];

212$row[title] = cn_substr;

213if

214{

215$row[title] = font color=.$row[color]..$row[title]./font;

216}

217if)

218{

219$row[title] = .$row[title].;

220}

221$row[textlink] = a href=.$row[filename]..$row[title]./a;

222$row[plusurl] = $row[phpurl] = $GLOBALS[cfg_phpurl];

223$row[memberurl] = $GLOBALS[cfg_memberurl];

224$row[templeturl] = $GLOBALS[cfg_templeturl];

052//获得筛选参数

053foreach {

054$pageaddurl .= ? .snail_filter.=.snail_filter : ;

055}

147//h3rint_r;exit;//13,12,11,10,9,5,4 文章id串

148if

149{

150return ;

151}

152else

153{

154$query = Select arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,

155tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath

156$addField

157from `dede_archives` arc left join `dede_arctype` tp on arc.typeid=tp.id

158$addJoin

159where arc.id in $ordersql ;

160}

161$t2 = ExecTime;

162//echo $t2-$t1;

163}

164$this-dsql-SetQuery;

165//print_r;exit;

166//die);

167$this-dsql-Execute;

168$t2 = ExecTime;

169//echo $t2-$t1;exit;

170$artlist = ;

171$this-dtp2-LoadSource;

172$GLOBALS[autoindex] = 0;

173for

001//获得动态的分页列表

002function GetPageListDM

003{

004/*****************************************************************************************/

005if{

01/*字符过滤函数*/

02function snail_filter {

03if {

04$str = str_replace,

06array,

07$str);

08} else if {

09$farr = array/isU,

11/on[a-zA-Z]+\s*=/isU,

12);

13$tarr = array;

17$str = preg_replace;

18$str = str_replace,

20array,

21$str);

22}

23return $str;

24}

然后,在include/arc.listview.class.php里面增加排序判断及分页的概念,并排除myorder字段

一,修改CountRecord,在第二行的下面

056//获得?和?的链接

057if

058{

059$prepage.=lia href=.$purl.PageNo=$prepagenum.$pageaddurl..$uaprevious./a/li\r\n;

060$indexpage=lia href=.$purl.PageNo=1.$pageaddurl..$uahome./a/li\r\n;

061}

062else

063{

064$indexpage=lia.$uahome./a/li\r\n;

065}

066if

067{

068$nextpage.=lia href=.$purl.PageNo=$nextpagenum.$pageaddurl..$uanext./a/li\r\n;

069$endpage=lia href=.$purl.PageNo=$totalpage.$pageaddurl..$ualastpage./a/li\r\n;

070}

071else

072{

073$endpage=lia.$ualastpage./a/li\r\n;

074}

075//获得数字链接

076$listdd=;

077$total_list = $list_len * 2 + 1;

078if

079{

080$j = $this-PageNo-$list_len;

081$total_list = $this-PageNo+$list_len;

082if

083{

084$total_list=$totalpage;

085}

086}

087else

088{

089$j=1;

090if

091{

092$total_list=$totalpage;

093}

094}

095for

096{

097if

098{

099$listdd.= li class=\active pagenum\a$j/a/li\r\n;

100}

101else

102{

103$listdd.=li class=\pagenum\a href=.$purl.PageNo=$j.$pageaddurl..$j./a/li\r\n;

104}

105}

106$plist = ;

107if) $plist .= $indexpage;

108if) $plist .= $prepage;

109if) $plist .= $listdd;

110if) $plist .= $nextpage;

111if) $plist .= $endpage;

112if) $plist .= $optionlist;

113if) $plist .= $maininfo;

114if

115{

116$plist = str_replace;

117$plist = str_replace;

118$plist = preg_replace/i,-\\1.html,$plist);

119}

120return $plist;

011$uatotal=共;

43//新增结束

106unset;//删除一个字段

107foreach {

108$mywhere= AND $addtable..snail_filter. = .snail_filter).;

109}

110$filtersql .= ? $mywhere : ;

111}

112}

113else

114{

115$addField = ;

116$addJoin = ;

117}

118//print_r;exit;//取出所有自概念字段 DEDE6久阁模板网

119//print_r;exit;//left join `dede_addonarticle` on arc.id = dede_addonarticle.aid

120//假如不需要默认的sortrank或id排序,用联合查看(数据量大时很缓慢)

121if)

122{

123$query = Select arc.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,

124tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath

125$addField

126from `dede_archives` arc

127left join `dede_arctype` tp on arc.typeid=tp.id

128$addJoin

129WHERE {$this-addSql} $filtersql $ordersql LIMIT $limitstart,$row;

130}

131//一般状况先从arctiny表查出ID,然后按ID查看(速度飞快)

132else

133{

134$t1 = ExecTime;

135$ids = array;

136$query = SELECT id FROM `dede_arctiny` arc $addJoin WHERE {$this-addSql} $filtersql $ordersql LIMIT $limitstart,$row ;

137//print_r;exit;//SELECT id FROM `dede_arctiny` arc left join `dede_addonarticle` on arc.id = dede_addonarticle.aid WHERE arc.arcrank -1 And like %,1,% ) AND dede_addonarticle.mystate = 马上开始 AND dede_addonarticle.mytype = 资金投入返现 order by arc.id desc LIMIT 0,16

138$this-dsql-SetQuery;

139$this-dsql-Execute;

140//die);

141while)

142{

143$ids[] = $arr[id];

144}

145//print_r;exit;

146$idstr = join;

1a class=ib h3adding-right href=/h3lus/list.h3hh3?tid={dede:field.tyh3eid/}myorder=hot{dede:h3hh3}if{echo sh3an最热/sh3an;}else{echo 最热;}{/dede:h3hh3}/a

030//排序方法

031$ordersql = ;

032if {

033$ordersql= order by arc.id $orderWay;

034}

035else if {

036$ordersql = order by arc.click $orderWay;

037}

038else if {

039$ordersql = order by arc.lastpost $orderWay;

040}else if {

041$ordersql = order by arc.weight $orderWay;

042}

043else {

044$ordersql= order by arc.sortrank $orderWay;

045}

046//新增综合排序:默认 最热 最新 价高 价低

047$addtable = $this-ChannelUnit-ChannelInfos[addtable];

048if{

049$orderby=sortrank;

050$ordersql = order by arc.sortrank $orderWay;

051}elseif{

052$orderby=hot;

053$ordersql = order by arc.click $orderWay;

054}

055elseif{

056$orderby=id;

057$ordersql = order by arc.id $orderWay;

058}

059elseif{

060$orderby=price_high;

061$ordersql = order by .$addtable..price .$orderWay;

062}

063elseif{

064$orderby=price_low;

065$ordersql = order by .$addtable..price asc;

066}

067elseif{

068$orderby=mian_high;

069$ordersql = order by .$addtable..mian .$orderWay;

070}

071elseif{

072$orderby=mian_low;

073$ordersql = order by .$addtable..mian asc;

074}

075else{

076$ordersql= order by arc.id $orderWay;

077}

078//多条件查看新增,获得附加表的有关信息/

079////获得一个单列的文档列表继续

080if

081{

082$addJoin = left join `$addtable` on arc.id = .$addtable..aid ;

083$addField = ;

084$fields = explode;

085foreach

086{

087$nfields[$v] = $k;

088}

089if !empty)

090{

091foreach

092{

093if)

094{

095if) {

096$addField .= ,.$addtable...$k. as .$arr[rename];

097}

098else {

099$addField .= ,.$addtable...$k;

100}

101}

102}

103}

104if ){

105$myget=$_GET;

修改为

1$cquery = SELECT COUNT AS dd FROM `dede_arctiny` arc $addJoin WHERE .$this-addSql.$filtersql;

012$uarecords=条记录;

013}else{

014$uahome= Home ;

015$uaprevious= Previous ;

016$uanext= Next ;

017$ualastpage= Last Page ;

018$uapage= Page ;

019$uatotal= Total ;

020$uarecords= Records. ;

021}

022global $cfg_rewrite;

023$prepage = $nextpage = ;

024$prepagenum = $this-PageNo-1;

025$nextpagenum = $this-PageNo+1;

026if)

027{

028$list_len=3;

029}

030$totalpage = ceil;

031if

032{

033return /ulul class=\margin pagination border-main pageinfo\lia .$uatotal. 1 .$uapage./.$this-TotalResult..$uarecords./a/li\r\n;

034}

035if

036{

037return /ulul class=\margin pagination border-main pageinfo\lia .$uatotal. 0 .$uapage./.$this-TotalResult..$uarecords./a/li\r\n;

038}

039$maininfo = /ulul class=\margin pagination border-main pageinfo\lia .$uatotal. strong{$totalpage}/strong.$uapage.strong.$this-TotalResult./strong.$uarecords./a/li\r\n;

040$purl = $this-GetCurUrl;

041if

042{

043$nowurls = ereg_replace;

044$nowurls = explode;

045$purl = $nowurls[0];

046}

047$geturl = tid=.$this-TypeID.TotalResult=.$this-TotalResult.;

048$purl .= ?.$geturl;

049$optionlist = ;

050//$hidenform = input type=hidden name=tid value=.$this-TypeID.\r\n;

051//$hidenform .= input type=hidden name=TotalResult value=.$this-TotalResult.\r\n;

261if){//已结束的活动

262$artlist2 .= $this-dtp2-GetResult;

263}else{

264$artlist1 .= $this-dtp2-GetResult;

265}

266$artlist=$artlist1.$artlist2;

267}else{

268$artlist .= $this-dtp2-GetResult;

269}

270//$i2=$i2+1;

271//print_r;

272}//if hasRow

273//exit;

274}//Loop Col

275//print_r;exit;

276if

277{

278$i += $col - 1;

279$artlist .= /p\r\n;

280}

281$row2[] = $row;

282}//Loop Line

283//print_r;exit;

284$t3 = ExecTime;

285//echo ;

286$this-dsql-FreeResult;

287//die);

288return $artlist;

289}

四,动态分页函数整体替换为

模板如下

在if)cfgneedtyh3eid2))cfg_need_tyh3eid2 = N的下面

增加

01//新增,多条件筛选 ,获得附加表的有关信息

02$addtable = $this-ChannelUnit-ChannelInfos[addtable];

03if

04{

05$addJoin = LEFT JOIN `$addtable` ON arc.id = .$addtable..aid ;

06$addField = ;

07$fields = explode;

08foreach

09{

10$nfields[$v] = $k;

11}

12if !empty)

13{

14foreach

15{

16if)

17{

18if) {

19$addField .= ,.$addtable...$k. as .$arr[rename];

20}

21else {

22$addField .= ,.$addtable...$k;

23}

24}

25}

26}

27if ){

28$myget=$_GET;

2、继续找到

1$cquery = SELECT COUNT AS dd FROMdede_arctinyarc WHERE .$this-addSql;

3a class=ib h3adding-right href=/h3lus/list.h3hh3?tid={dede:field.tyh3eid/}myorder=h3rice_high{dede:h3hh3}if{echo sh3an价高/sh3an;}else{echo 价高;}{/dede:h3hh3}/a

006$uahome=首页;

007$uaprevious=?;

008$uanext=?;

4a class=ib h3adding-righthref=/h3lus/list.h3hh3?tid={dede:field.tyh3eid/}myorder=h3rice_low{dede:h3hh3}if{echo sh3an价低/sh3an;}else{echo 价低;}{/dede:h3hh3}/a

第一,在自概念函数中\include\extend.func.php增加非法过滤函数

174//h3rint_r;exit;调用条数20

175{

176if

177{

178$artlist .= p\r\n;

179}

180for

181{

182if)

183//print_r;exit;

184{

185$GLOBALS[autoindex]++;

186$ids[$row[id]] = $row[id];

列表模板上增加排序,myorder=hot注意,其中增加了一个虚拟字段myorder,这个字段后台并没添加.他只不过一个排序的标志符,需要最后排除掉.

另外,模板上用到了{dede:php}标签,需要在后台管理软件设置.系统基本参数,其它设置中,去掉对php模板标签的限制.

121}