Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

首页n格的问题整理与解决[最后更新:2007.11.05 JS调用附件]

[复制链接]
sxj7 发表于 2007-10-18 21:43:38 | 显示全部楼层
首页四格如何调用某个板块的某个分类,查找很多资料,没有这方面的!

就是如下代码,让他能调用某个分类呢?就是typeid这个,不是板块fid,希望高手不吝赐教,谢谢!
引用:
//新贴
$hack_cut_str = 26; //标题字数
$hack_cut_strauthor = 9;
$hack_forumid = "47";//要显示的论坛的fid
$new_post_threadlist = array();
$nthread = array();
$query = $db->query("SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHERE t.fid<>'$fid' AND f.fid=t.fid AND t.displayorder not in (-1,-2) AND f.fid in($hack_forumid) ORDER BY t.dateline DESC LIMIT 0, 9");
while($nthread = $db->fetch_array($query)) {
        $nthread['forumname'] = ereg_replace('<[^>]*>','',$nthread['name']);
        $nthread['view_subject'] = cutstr($nthread['subject'],$hack_cut_str);
        $nthread['view_author'] = cutstr($nthread['author'],$hack_cut_strauthor);
        $nthread['date']= gmdate("$dateformat $timeformat", $nthread['dateline'] + $timeoffset * 3600);
        $nthread['lastreplytime']= gmdate("$dateformat $timeformat", $nthread[lastpost] + ($timeoffset * 3600));
        if($nthread['highlight']) {
                $string = sprintf('%02d', $nthread['highlight']);
                $stylestr = sprintf('%03b', $string[0]);
                $nthread['highlight'] = 'style="';
                $nthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
                $nthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
                $nthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
                $nthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
                $nthread['highlight'] .= '"';
        } else {
                $nthread['highlight'] = '';
        }
        $new_post_threadlist[] = $nthread;
}
$curdata = "\$new_post_threadlist = ".arrayeval($new_post_threadlist).";\n\n";
回复

使用道具 举报

习明 发表于 2007-10-18 23:06:24 | 显示全部楼层
  1. $query = $db->query("SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHERE t.fid<>'$fid' AND f.fid=t.fid AND t.displayorder not in (-1,-2) AND f.fid in($hack_forumid) ORDER BY t.dateline DESC LIMIT 0, 9");
复制代码
改为
$query = $db->query("SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHERE t.typeid=XXX AND t.fid<>'$fid' AND f.fid=t.fid AND t.displayorder not in (-1,-2) AND f.fid in($hack_forumid) ORDER BY t.dateline DESC LIMIT 0, 9");

XXX为分类ID 如需查询多个 将红色处改为
  1. t.typeid in (XXX,YYY,ZZZ) AND
复制代码
回复

使用道具 举报

whun 发表于 2007-10-19 13:52:55 | 显示全部楼层
如何增加首页n格图片轮换的图片类型
现在的都局限在jpg,能不能增加gif,png这种图片格式?

怎么加?
回复

使用道具 举报

习明 发表于 2007-10-19 14:06:11 | 显示全部楼层

回复 475# 的帖子

有一些版本的图片轮播是可以支持的 具体情况要使用哪一种N格而定
回复

使用道具 举报

sxj7 发表于 2007-10-19 16:35:39 | 显示全部楼层
原帖由 习明 于 2007-10-18 23:06 发表
$query = $db->query("SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHERE t.fid'$fid' AND f.fid=t.fid AND t.displayorder not in (-1,-2) AND f.fid in($hack_forumid) ORDER BY t.dateli ...

刚刚看到,先回个帖子感谢,在去试试,谢谢习明,人不错的说
回复

使用道具 举报

sxj7 发表于 2007-10-20 23:42:49 | 显示全部楼层

回复 476# 的帖子

测试结果OK,谢谢习明,还有一个问题,能否调用的时候显示分类名称呢?

例如调用后显示:   [技术交流] 主题XXXXXXXXXXXXX
[技术交流] 为分类不是板块
回复

使用道具 举报

阳光E人 发表于 2007-10-21 00:42:19 | 显示全部楼层
请教如何去掉标题超过规定的字数后的省略号?
回复

使用道具 举报

习明 发表于 2007-10-21 10:59:14 | 显示全部楼层

回复 478# 的帖子

$query = $db-&gt;query(&quot;SELECT t.*, f.name, tt.name as typename FROM {$tablepre}threads t, {$tablepre}forums f, {$tablepre}threadtypes tt WHERE t.typeid=tt.typeid AND t.typeid=XXX AND t.fid&lt;&gt;'$fid' AND f.fid=t.fid AND t.displayorder not in (-1,-2) AND f.fid in($hack_forumid) ORDER BY t.dateline DESC LIMIT 0, 9&quot;);


然后$nthread['typename']就是分类名
回复

使用道具 举报

习明 发表于 2007-10-21 11:02:23 | 显示全部楼层

回复 479# 的帖子

截取标题时用 cutstr($title, $length, $suffix)
如果$suffix没有 就会使用默认的 ... 作为后缀
不想加后缀的话写成 cutstr($title, $length, '')
回复

使用道具 举报

sxj7 发表于 2007-10-21 21:19:38 | 显示全部楼层
原帖由 习明 于 2007-10-21 10:59 发表


然后$nthread['typename']就是分类名



试试去,谢谢习明
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-9-23 01:26 , Processed in 0.112951 second(s), 15 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表