在thred_tid_fun中增加两个自定义函数
//按照文章id值调用指定文章数据 $id为 20220326老魏增加 function thread_tid_read_id($tid) { // hook model_thread_tid_read_start.php $r = thread_tid__read_message(array('tid' => $tid)); //$r = db_find_one('well_website_data',$cond = array('tid' => $tid)); // hook model_thread_tid_read_end.php return $r; } //按照文章id值调用指定文章数据 $id为 20220326老魏增加 function thread_tid__read_message($cond = array(), $orderby = array(), $col = array(), $d = NULL) { // hook model_data__read_start.php $r = db_find_one('website_data', $cond, $orderby, $col, $d); // hook model_data__read_end.php return $r; }
在read.html中调用,根据内容页tag标签调用相关文章
<!--老魏添加--> <?php if ($thread['tag']) { $tagids = array_keys($thread['tag_fmt']); $arrlist = well_tag_thread_find($tagids, 1, 100); !$arrlist and $arrlist = well_tag_thread__find(array(), array('id' => 1), 1, 100); if ($arrlist) { $count = count($arrlist); $total = $count > $pagesize ? $pagesize : $count; $tidarr = $count > 20 ? array_rand($arrlist, $total) : array_keys($arrlist); $arrlist = well_thread_find_asc($tidarr, 5); } } ?> <?php if (!empty($arrlist)) { ?> <?php foreach($arrlist as $va2) { ?> <h2><?php echo $thread['subject'];?>推荐答案</h2> <?php $myval2=thread_tid_read_id($va2['tid']) ?> <!--<?php print_r($myval2); ?>--> <!--<?php echo $myval2['message'];?>--> <?php echo substr($myval2['message'],0,strrpos($myval2['message'] ,"<h2>"));?> <?php } ?> <?php } ?> <!--老魏添加-->