互联网 频道

如何控制首页论坛公告的标题宽度

  【it168 软件频道】Discuz!7.0是康盛创想(Comsenz)公司于2008年12月份发布的一款论坛BBS建站产品。Discuz!7.0中,看到论坛中有会员在问如何控制公告标题显示的宽度,现给出一临时解决办法,希望能帮到大家。

  一、当公告标题太长时,公告的开始时间会被截取,导致会员看不到时间。


图1

  二、解决方法

  1、打开论坛根目录下的 index.php,找到:

if(!$gid) {
        $announcements = '';
        if($_DCACHE['announcements']) {
                $readapmids = !empty($_DCOOKIE['readapmid']) ? explode('D', $_DCOOKIE['readapmid']) : array();
                foreach($_DCACHE['announcements'] as $announcement) {
                        if(empty($announcement['groups']) || in_array($groupid, $announcement['groups'])) {
                                if(empty($announcement['type'])) {
                                        $announcements .= '

  • '.$announcement['subject'].
                                                    '('.gmdate($dateformat, $announcement['starttime'] + $timeoffset * 3600).')
  • ';
                                    } elseif($announcement['type'] == 1) {
                                            $announcements .= '
  • '.$announcement['subject'].
                                                    '('.gmdate($dateformat, $announcement['starttime'] + $timeoffset * 3600).')
  • ';
                                    }
                            }
                    }
            }

      修改为:

    if(!$gid) {
            $announcements = '';
            if($_DCACHE['announcements']) {
                    $readapmids = !empty($_DCOOKIE['readapmid']) ? explode('D', $_DCOOKIE['readapmid']) : array();
                    foreach($_DCACHE['announcements'] as $announcement) {
                            if(empty($announcement['groups']) || in_array($groupid, $announcement['groups'])) {
                                    if(empty($announcement['type'])) {
                                            $announcements .= '

  • '.''.$announcement['subject'].''.
                                                    '('.gmdate($dateformat, $announcement['starttime'] + $timeoffset * 3600).')
  • ';
                                    } elseif($announcement['type'] == 1) {
                                            $announcements .= '
  • '.''.$announcement['subject'].''.
                                                    '('.gmdate($dateformat, $announcement['starttime'] + $timeoffset * 3600).')
  • ';
                                    }
                            }
                    }
            }

      修改完毕,保存文件。

      2、打开模板文件 css_common.htm,找到:#ann li { overflow: hidden;  padding-left: 10px; white-space: nowrap; }


      在其下面添加如下css代码:

      #ann a:hover { text-decoration: none; }

      #ann span { display: block; float: left; width: 100px; height: 30px; overflow: hidden; }

      其中span属性 width: 100px; 中的100 为标题的长度,请根据自己的需要修改大小。

      修改完毕,保存文件。

      3、到后台更新模板缓存。

      三、修改长度后,显示如下:


    图2
    0
    相关文章