前言:由于整站系统用了几个系统,所以一直有在BBS上展示资讯和其他内容的需求,Discuz!7的调用外部数据的功能用起来非常顺手,但是不知道为什么到X系列就没了,一直咨询官方也没有可操作的方案,本来挺期待官方的一系列培训的,但是确实没耐心听下去,翻了一下记录也没有说如何去调外部数据。最后发现,原来不懂程序的小白的确很悲哀...
系统说明:
个人的小站用了PHPCMS V9做主站,这个系统很好用,超好用,不过PC官方似乎不愿意投入太多继续开发了,郁闷一下。另外用了74CMS的人才系统,也是非常好用,非常顺手的人才系统。这三个系统的会员系统已经整合UC,打通会员登陆。
改动文件:
source\module\forum\forum_index.php
template\default\forum\discuz.htm
forum_index.php
文件里先要增加数据查询的语句,如下:
- $v9news = get_hr369_news(6);
- $v9hr = get_hr369_news(8);
- $v9manage = get_hr369_news(9);
- $v9zhichang = get_hr369_news(10);
- $qsjob = get_hr369_job(99);
复制代码
- function get_hr369_news($parentid){
- $query = DB::query("SELECT catid,catname,url FROM `hr369_v9`.`v9_category` WHERE parentid={$parentid} and siteid=1");
- while($row = DB::fetch($query)){
- $cc1_catid_array[] = $row['catid'];
- $cc1[$row['catid']]['catname'] = $row['catname'];
- $cc1[$row['catid']]['url'] = $row['url'];
- }
- $cc1_catid = implode($cc1_catid_array,',');
- $query = DB::query("SELECT * FROM `hr369_v9`.`v9_news` WHERE catid in ({$cc1_catid}) and status=99 order by id desc limit 0,8");
- while($row = DB::fetch($query)){
- $row['catname'] = $cc1[$row['catid']]['catname'];
- $row['caturl'] = $cc1[$row['catid']]['url'];
- $re['list'][] = $row;
- }
- $query = DB::query("SELECT * FROM `hr369_v9`.`v9_position_data` WHERE catid in ({$cc1_catid}) AND thumb=1 order by id desc limit 0,1");
- while($row = DB::fetch($query)){
- $row['catname'] = $cc1[$row['catid']]['catname'];
- $row['caturl'] = $cc1[$row['catid']]['url'];
- $row['url'] = "http://www.hr369.com/index.php?m=content&c=index&a=show&catid={$row['catid']}&id={$row['id']}";
- $row['title'] = $arr['title'];
- $row['inputtime'] = $arr['inputtime'];
- $re['pic'][] = $row;
- }
- return $re;
- }
- function get_hr369_job($parentid){
- $query = DB::query("SELECT j.id , j.jobs_name , j.companyname , j.company_id FROM `hr369_job`.`qs_promotion` p , `hr369_job`.`qs_jobs` j where p.`cp_promotionid` = 1 and p.`cp_jobid` = j.id order by p.cp_id DESC");
- while($row = DB::fetch($query)){
- $re['list'][] = $row;
- }
- return $re;
- }
复制代码 discuz.htm需要增加展示内容:
-
- <div id="portal_block_615" class="xbs_1 block move-span">
- <DIV class="blocktitle title" style=""><SPAN class=titletext style="COLOR: #663399 !important; MARGIN-LEFT: 8px">人力资源招聘</SPAN><SPAN class=subtitle style="FLOAT: right; MARGIN-RIGHT: 8px"><A style="COLOR: #663399 !important" href="http://job.hr369.com/user/login.php?url=/user/company/company_jobs.php?act=addjobs" target=_blank>发布招聘</A></SPAN></DIV><div id="portal_block_615_content" class="dxb_bc"><div class="module cl xl xl1">
- <ul>
- <!--{loop $qsjob['list'] $id $qsjob}-->
- <li><a href="http://job.hr369.com/company/company-show.php?id=$qsjob[company_id]" target="_blank" title="$qsjob[companyname]">$qsjob[companyname]</a> 招聘 <a href="http://job.hr369.com/company/company-jobs.php?id=$qsjob[id]" target="_blank" title="$qsjob[jobs_name]"><strong>$qsjob[jobs_name]</strong></a></li>
- <!--{/loop}-->
- </ul>
- </div></div></div>
-
- <div id="portal_block_615" class="xbs_1 block move-span">
- <DIV class="blocktitle title" style=""><SPAN class=titletext style="COLOR: #663399 !important; MARGIN-LEFT: 8px">新闻资讯</SPAN><SPAN class=subtitle style="FLOAT: right; MARGIN-RIGHT: 8px"><A style="COLOR: #663399 !important" href="http://news.hr369.com/" target=_blank>更多内容</A></SPAN></DIV><div id="portal_block_615_content" class="dxb_bc"><div class="module cl xl xl1">
- <ul>
- <!--{loop $v9news['list'] $id $v9news}-->
- <li>[<a href="$v9news[caturl]" target="_blank" title="$v9news[catname]">$v9news[catname]</a>] <a href="$v9news[url]" target="_blank" title="$v9news[title]">$v9news[title]</a></li>
- <!--{/loop}-->
- </ul>
- </div></div></div>
- <div id="portal_block_615" class="xbs_1 block move-span">
- <DIV class="blocktitle title" style=""><SPAN class=titletext style="COLOR: #663399 !important; MARGIN-LEFT: 8px">HR智库</SPAN><SPAN class=subtitle style="FLOAT: right; MARGIN-RIGHT: 8px"><A style="COLOR: #663399 !important" href="http://hr.hr369.com/" target=_blank>更多内容</A></SPAN></DIV><div id="portal_block_615_content" class="dxb_bc"><div class="module cl xl xl1">
- <ul>
- <!--{loop $v9hr['list'] $id $v9hr}-->
- <li>[<a href="$v9hr[caturl]" target="_blank" title="$v9hr[catname]">$v9hr[catname]</a>] <a href="$v9hr[url]" target="_blank" title="$v9hr[title]">$v9hr[title]</a></li>
- <!--{/loop}-->
- </ul>
- </div></div></div>
- <div id="portal_block_615" class="xbs_1 block move-span">
- <DIV class="blocktitle title" style=""><SPAN class=titletext style="COLOR: #663399 !important; MARGIN-LEFT: 8px">管理之家</SPAN><SPAN class=subtitle style="FLOAT: right; MARGIN-RIGHT: 8px"><A style="COLOR: #663399 !important" href="http://manage.hr369.com/" target=_blank>更多内容</A></SPAN></DIV><div id="portal_block_615_content" class="dxb_bc"><div class="module cl xl xl1">
- <ul>
- <!--{loop $v9manage['list'] $id $v9manage}-->
- <li>[<a href="$v9manage[caturl]" target="_blank" title="$v9manage[catname]">$v9manage[catname]</a>] <a href="$v9manage[url]" target="_blank" title="$v9manage[title]">$v9manage[title]</a></li>
- <!--{/loop}-->
- </ul>
- </div></div></div>
- <div id="portal_block_615" class="xbs_1 block move-span">
- <DIV class="blocktitle title" style=""><SPAN class=titletext style="COLOR: #663399 !important; MARGIN-LEFT: 8px">职场</SPAN><SPAN class=subtitle style="FLOAT: right; MARGIN-RIGHT: 8px"><A style="COLOR: #663399 !important" href="http://zhichang.hr369.com/" target=_blank>更多内容</A></SPAN></DIV><div id="portal_block_615_content" class="dxb_bc"><div class="module cl xl xl1">
- <ul>
- <!--{loop $v9zhichang['list'] $id $v9zhichang}-->
- <li>[<a href="$v9zhichang[caturl]" target="_blank" title="$v9zhichang[catname]">$v9zhichang[catname]</a>] <a href="$v9zhichang[url]" target="_blank" title="$v9zhichang[title]">$v9zhichang[title]</a></li>
- <!--{/loop}-->
- </ul>
- </div></div></div>
复制代码 这样就完成了直接从数据库查询数据到论坛首页上展示了。
演示可以到我的小站中看
http://bbs.hr369.com/
菜鸟,希望大家多多指正。
|