随机显示Banner http://www.backlog.cn/index.php/forums/viewthread/17/ 以前用js来更换Banner的背景以及主题,可是每次登陆的时候由于登陆页面是用js直接跳转上一页的,所以每次自动运行到首页的scripts脚本就过不去了,为此我苦恼了好久. 现在,问题终于解决了.直接用php程序来随机调用Banner,真是方便啊! 现在贡献给需要的同志吧: 首先,将下列代码转寸为php程序. 代码: <?php $folder = '这里放你需要调用Banner的文件夹,如果是与Randombanner.php同一个文件夹里就保持空白'; // Space seperated list of extensions, you probably won't have to change this. $exts = 'jpg jpeg png gif'; $files = array(); $i = -1; // Initialize some variables if ('' == $folder) $folder = './'; $handle = opendir($folder); $exts = explode(' ', $exts); while (false !== ($file = readdir($handle))) { foreach($exts as $ext) { // for each extension check the extension if (preg_match('/\.'.$ext.'$/i', $file, $test)) { // faster than ereg, case insensitive $files[] = $file; // it's good ++$i; } } } closedir($handle); // We're not using it anymore mt_srand((double)microtime()*1000000); // seed for PHP < 4.2 $rand = mt_rand(0, $i); // $i was incremented as we went along header('Location: '.$folder.$files[$rand]); // Voila! ?> 然后,用/xxx/xxx/xxx/randombanner.php来调用就可以了. 希望大家喜欢啊! :xizao:
如何在首页调用论坛最新帖子? http://www.backlog.cn/index.php/forums/viewthread/16/ 这个问题比较简单,只用将下列代码放到适当的位置即可. 代码: <table> <tr> <td>标题</td> <td>作者</td> <td>发表时间</td> <td>贴数</td> <td>浏览</td> <td>最后回复</td> </tr> {exp:forum:topic_titles orderby="post_date" sort="asc" limit="10"} <tr> <td><a href="{thread_path=forums/viewthread}">{title}</a></td> <td><a href="{profile_path=forums/member}">{author}</a></td> <td>{topic_date format="%m/%d/%Y %h:%i %a"}</td> <td>{post_total}</td> <td>{views}</td> <td>On: {last_post_date format="%m/%d/%Y %h:%i %a"}<br /> By: <a href="{last_author_profile_path=forums/member}">{last_author}</a></td> </tr> {/exp:forum:topic_titles} </table>
如何在首页显示画廊里的图片? http://www.backlog.cn/index.php/forums/viewthread/15/ 1:首先要建立一个新模版.比如:weblog/showrand 2.将如下的代码放入模版中: 代码: {exp:gallery:entries gallery="yourgalleryname" orderby="random" columns="1" rows="1"} <table class="tableBorder" cellpadding="6" cellspacing="1" border="0" width="130px" align=center> <tr> <th align="center">Random Image</th> </tr> {entries} {row_start}<tr>{/row_start} {row} <td class="thumbs"> <a href="{id_path=gallery/image_med}" onclick="window.open(this.href, '_blank', 'width=700,height=500,location=no,menubar=no,resizable=yes,scrollbars=yes'); return false;" >< img src="{thumb_url}" class="border" width="{thumb_width}" height="{thumb_height}" border="0" title="{title}" alt="{title}" > <br /> {title} </a> </td> </td> {/row} {row_blank}<td class="thumbs"> </td>{/row_blank} {row_end}</tr>{/row_end} {/entries} </table> {/exp:gallery:entries} 3.最后,用{embed="weblog/showrand"}语句,或者IFRAME将它放到你所需要显示的地方.