免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3387 | 回复: 4
打印 上一主题 下一主题

dz数据调用问题,听说CU大牛多,希望能帮忙解决 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-10-13 13:21 |只看该作者 |倒序浏览
一个风格模板的问题大家帮忙看看能不能帮忙搞定
原帖地址http://www.discuz.net/forum.php? ... 6discuz_version%3D2此风格虽然作者发布了,但有一些问题,所以希望会PHP的朋友看一下,只需要能实现下面的数据调用的代码就可以了!
数据是直接从数据库调用的,但具体怎么调用就不知道 了,大家帮忙看看

//招聘信息首页调用
$hack_cut_str = 30; //标题字数
$hack_cut_strauthor = 9;
$hack_forumid = "52";//要显示的论坛的fid
$new_zhaopin_threadlist = array();
$zhaopinthread = array();
$query = $db->query("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.fid<>'$fid' AND f.fid=t.fid AND t.displayorder>=0 AND f.fid in($hack_forumid)  ORDER BY t.dateline DESC LIMIT 0, 8");
while($zhaopinthread = $db->fetch_array($query)) {
        $zhaopinthread['forumname'] = ereg_replace('<[^>]*>','',$zhaopinthread['name']);
        $zhaopinthread['view_subject'] = cutstr($zhaopinthread['subject'],$hack_cut_str);
        $zhaopinthread['view_author'] = cutstr($zhaopinthread['author'],$hack_cut_strauthor);
        $zhaopinthread['date']= gmdate("$dateformat $timeformat", $zhaopinthread['dateline'] + $timeoffset * 3600);
        $zhaopinthread['lastreplytime']= gmdate("$dateformat $timeformat", $zhaopinthread[lastpost] + ($timeoffset * 3600));
        if($zhaopinthread['highlight']) {
                $string = sprintf('%02d', $zhaopinthread['highlight']);
                $stylestr = sprintf('%03b', $string[0]);
                $zhaopinthread['highlight'] = 'style="';
                $zhaopinthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
                $zhaopinthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
                $zhaopinthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
                $zhaopinthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
                $zhaopinthread['highlight'] .= '"';
        } else {
                $zhaopinthread['highlight'] = '';
        }
        $new_zhaopin_threadlist[] = $zhaopinthread;
}
//招聘结束

这是根目录下index.php里的代码
<div class="news_show">
             <div class="news_index">
                        <h3>招聘信息</h3>
                        <div class="news_list">
                                <!--{loop $new_zhaopin_threadlist $zhaopinthread}-->
                                <!--{if $zhaopinthread[replies]}-->
                                        <li><a href="viewthread.php?tid=$zhaopinthread[tid]" $zhaopinthread['highlight']>$zhaopinthread[view_subject]</a></li>
                                        <!--{else}-->
                                        <li><a href="viewthread.php?tid=$zhaopinthread[tid]" $zhaopinthread['highlight']>$zhaopinthread[view_subject]</a></li>
                                        <!--{/if}-->
                                <!--{/loop}-->
                        </div>
                </div>
                </div>

这是模版discuz.htm里的部份代码

论坛徽章:
0
2 [报告]
发表于 2010-10-13 22:29 |只看该作者
本帖最后由 a.a 于 2010-10-13 22:31 编辑

$query = $db->query("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.fid<>'$fid' AND f.fid=t.fid AND t.displayorder>=0 AND f.fid in($hack_forumid)  ORDER BY t.dateline DESC LIMIT 0, 8");
上面的查出结果

模版中:
$string = sprintf('%02d', $zhaopinthread['highlight']);
                $stylestr = sprintf('%03b', $string[0]);
                $zhaopinthread['highlight'] = 'style="';
                $zhaopinthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
                $zhaopinthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
                $zhaopinthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
                $zhaopinthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
                $zhaopinthread['highlight'] .= '"';
显示结果,并且定义格式,你只要大概看一下模板使用方法就知道了。//和你一样正在学习中

论坛徽章:
0
3 [报告]
发表于 2010-10-14 09:06 |只看该作者
模板使用方法

在那里看呀,官方有相关的文档吗?
能加一下QQ吗,我的377835666

论坛徽章:
0
4 [报告]
发表于 2010-10-14 12:23 |只看该作者
回复 3# www4074


   目前主流的模板有两种一种叫做smarty 另外的就是个人比较喜欢的pear的 template http://pear.php.net/HTML_Template_IT,他上面有详细的使用说明。

论坛徽章:
0
5 [报告]
发表于 2010-10-15 20:27 |只看该作者
discuz 的模板标签很少的,
<!--{if}-->
<!--{elseif}-->
<!--{else}-->
<!--{loop}-->
<!--{eval}-->
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP