插件作者的标准出来了!Manyou诚邀开发者加盟!
“互联网平台开发者”特刊 有奖征集开发者
立即免费下载 Discuz!6.1.0正式版
Discuz! 6.1.0 使用说明
Discuz!NT2.5正式版发布
开放源码下载
UCenter Home 1.2 正式版发布
官方站 | 帮助文档
基于ECShop的网店托管-卖否
PHP就业培训直通车 | LAMP培训大连
Discuz!收费服务内容及价格
“感谢有你同行”手握手2008年数万元重奖志愿者
Discuz!/ECShop 专用官方虚拟主机
【九城-奇迹世界】专题活动开始了!
Comsenz 招聘信息
网店系统ECShop v2.6.0正式版火热发布
基于Discuz!的免费论坛空间5D6D
参与有奖社区调查 赢取台湾5日游
发新话题
打印

可以加入类似在 HTML 网页使用 Java Script 调用新帖??

可以加入类似在 HTML 网页使用 Java Script 调用新帖??

这是一个在vBulletion中的一例子
jsnew.php:

<?

//####################

// 在 HTML 网页使用 Java Script 调用 vBulletin 新帖,作者 cx(http://www.vnuke.com vgate@163.net)
// 使用方法:把本文件保存为 jsnew.php,放到你的 vB 论坛目录下
// 调用格式:<script language="javascript" src="http://your_vb_path/jsnew.php"></script>

$vbpath = "http://www.vnuke.com";  // 论坛 URL,最后不要加“/”
$callforums = '1,2,3,4';  // 希望调用论坛的 forumid,如果调用多个则用半角逗号隔开
$maxnews = 10;  // 调用新帖数量
$maxchars = 30;  // 标题最大字符数
$defaulticon = "$vbpath/images/icons/icon1.gif";  // 默认图标 URL
$timeformat = 'm月d日';  // 时间格式,比较详细的格式:Y年m月d日 H:i:s

//################################################################################


// 连接 MySQL!
include ("./admin/config.php");
$connect = mysql_connect($servername, $dbusername, $dbpassword) or die(mysql_errno() . ':' . mysql_error());
$select = mysql_select_db($dbname) or die(mysql_errno() . ':' . mysql_error());


// 查询!
$newthreads_query = "SELECT
thread.*,
iconpath
FROM
thread
LEFT JOIN icon USING (iconid)
WHERE
visible!=0
AND forumid IN (0,$callforums)
ORDER BY
lastpost DESC
LIMIT $maxnews";
$newthreads = mysql_query($newthreads_query)
or die(mysql_errno() . '<br>' . mysql_error() . "<br>$newthreads_query");

while ($newthread = mysql_fetch_array($newthreads)) {
        $newthread['type'] = ($newthread['replycount'] > 0) ? '回帖' : '新贴';
        $newthread['rawtitle'] = str_replace("'", ''', $newthread['title']);
        $newthread['title'] = (strlen($newthread['title']) > $maxchars) ? str_replace("'", ''', substr($newthread['title'], 0, $maxchars)) . '..' : $newthread['rawtitle'];
        $newthread['datetime'] = date($timeformat, $newthread['lastpost']);
        if (!$newthread['iconpath']) {
                $newthread['iconpath'] = $defaulticon;
        }

        $newthread['iconpath'] = strtolower($newthread['iconpath']);
        if (strpos($newthread['iconpath'], 'http://') === false) {
                $newthread['iconpath'] ="$vbpath/$newthread[iconpath]";
        }

        // 输出!这部分当然可以自由定义,还可以增加一些元素,例如回复数量($newthread[replycount])、浏览数量($newthread[views])
        echo "document.write('<a href=\"$vbpath/showthread.php?goto=lastpost&threadid=$newthread[threadid]\" title=\"$newthread[rawtitle] - $newthread[lastposter] $newthread[datetime]\" target=\"_blank\"><img src=\"$newthread[iconpath]\" border=\"0\" align=\"absmiddle\"> $newthread[type]:$newthread[title] | 浏览数量($newthread[postusername] | $newthread[forumtitle])</a><br />');";
}

?>



jsnew.html:

<script language="javascript" src="jsnew.php"></script>
[url=http://www.pczone.com.tw]PCZONE[/url]
原理应该一样吧
在压缩包utilities/目录有说明和相应的程序
Comsenz President & CEO
短消息太多 无暇一一回复 有事请联系相关负责人
为了您的问题及时解决 切勿发短消息给我

没事写写 Blog 想想看生活是多艰难的一件事情
谢谢站长的告知!!
utilities有好几个实用的工具,大家不妨去看看
如果需要调用某个讨论区的新文章,在 whatsnew.php 中找

        $query = mysql_query("SELECT subject, tid FROM $tablepre"."threads ORDER BY lastpost DESC LIMIT 0, $num") or die(mysql_error());

    从讨论区中找到要显示新文章的讨论区 fid,将上面语句改写为,并把下面的 xxx 替换为 fid 号即可.

        $query = mysql_query("SELECT subject, tid FROM $tablepre"."threads WHERE fid='xxx' ORDER BY lastpost DESC LIMIT 0, $num") or die(mysql_error());


如果我只要某二,三个forum显示最新文章,
不晓得可不可以在 fid='xxx' 中改成 fid='1,2,3'
只显示fid=1,fid=2,fid=3的最新文章
[url=http://www.pczone.com.tw]PCZONE[/url]
不可以这样 fid='1,2,3'
可以: fid='1' OR fid='2' OR fid='3'
Comsenz President & CEO
短消息太多 无暇一一回复 有事请联系相关负责人
为了您的问题及时解决 切勿发短消息给我

没事写写 Blog 想想看生活是多艰难的一件事情
发新话题
版块跳转